I would like to calculate means and st.devs of a column in table but I would like to calculate them for each new observation ex
library(tidyverse)
aa <- data.frame(aa = c(2, 3, 4, 5, 6, 7, 8)) %>%
mutate(aa1 = cumsum(aa), li = 1:n()) %>%
mutate(MeanAA = aa1/li)
aa = c(2, 3, 4, 5, 6, 7, 8)
mean(aa[1:2])
mean(aa[1:3])
sd(aa[1:2])
sd(aa[1:3])
I could do it for a mean but not for SD. I would like to see how sd is changing in relation to mean with increasing number of observations.