As you can see from this example it is easy to calculate running mean:
data <- data.frame(dats=c(3,4,NA,4,NA,NA,6,NA,8,1,4,NA,2,NA,NA,6,NA,NA,9,5,NA,8,NA,3))
data <- data %>% mutate(rmean = caTools::runmean(dats, 3, endrule="constant"))
But in some cases the mean calculated just from the only no-na value in the data. How can I prevent this and specify that I get the runmean only when a certain number of non-na values in the running window is used in mean calculation?