I have a list myList that contains 16 data.frames
List of 16
$ dataframe1 :'data.frame': 20 obs. of 60 variables:
..$ Stat : Factor w/ 16 levels "a","b",..: 16 16 16 16 16 16 16 16 16 16 ...
..$ P10 : num [1:31] 1 3 2 2 4 8 0 4 2 5 ...
..$ R : num [1:31] NA NA NA NA NA NA NA NA NA NA ...
..$ S : num [1:31] 0 7 7 1 5 9 3 9 6 2 ...
$ dataframe2 :'data.frame': 20 obs. of 60 variables:
..$ Stat : Factor w/ 16 levels "c","d",..: 16 16 16 16 16 16 16 16 16 16 ...
..$ P10 : num [1:31] 2 1 2 2 5 6 7 2 2 5 ...
..$ R : num [1:31] NA 1 NA NA 2 NA 4 NA NA NA ...
..$ S : num [1:31] 10 2 4 1 5 8 8 8 1 2 ...
...
..
I need the mean from each column and get the results in a data.frame.
dataframe1 dataframe2 ....
Stat NA NA
P10 6 7
R NA 3
S 12 14
... ... ... ...
I have this lapply(myList$variable1, mean) which returns me the results for one data.frame in that list.
ldply(myList, data.frame) does not include the mean function.
How would I do that for the whole list and bring it into one data.frame?
sapply(myList, colMeans, na.rm=TRUE)Variable1and that data frame has a column of data frames also calledVariable1...Error in FUN(X[[i]], ...) : 'x' must be numericfunction(y)needs to be run withfunction(x)though.