R purrr

library(tidyverse)

my_list<-list(
c(1,2,6),
c(4,7,1),
c(9,1,5)
)

my_list[[1]] %>% mean()
my_list %>% map_dbl(mean)
map(my_list,mean)
my_list %>% map(~ . *1)
my_list %>% map(~ . *2)

pop<-rnorm(10000)
n<-1:1000
m1<-rep(NA,length(n))

for (i in n){
x<-sample(pop,i)
m1[i]<-mean(x)
}
plot(m1,type="l")

Leave a Reply