This should be simple, but I can't work it out ...
I want to apply a function, eg. mean to each of the lower lists, eg. I want to return
$
1
$
1
$a [1] value_of_mean 1$
1
$b [1] value_of_mean 2$
2
$
2
$a [1] value_of_mean 3$
2
$b [1] value_of_mean 4
I am trying to use the purrr package
require(purrr)
mylist <- list("1"=list(a=runif(10), b=runif(10)), "2"=list(a=runif(10), b=runif(10)))
map(mylist, mean)
See Question&Answers more detail:os