I need 50 reputation to comment, but not to "answer", so this is a comment, and not an answer
Normally, the weighted average weights should add to 1, and in your sample it adds to 2
w=c(1/2,1,1/2)
sum(w)=2
maybe it should be?
w=c(1/4,1/2,1/4)
and you can get a moving average with the filter function
F <- filter(x, filter = w, method = c("convolution"), sides = 2)