Means from a list of data frames in R

后端 未结 2 637
梦毁少年i
梦毁少年i 2020-12-18 16:29

I am relatively new to R and have a complicated situation to solve. I have uploaded a list of over 1000 data frames into R and called this list x. What I want to do is take

2条回答
  •  一个人的身影
    2020-12-18 16:38

    If x is a list of 1000 dataframes, you can use lapply to return the means and variances of a subset of this list.

    ix = seq(1, 1000, 3)
    lapply(x[ix], function(df){
        #exclude the first column
        c(mean(df[,-1]), var(df[,-1]))
    })
    

提交回复
热议问题