Means from a list of data frames in R

后端 未结 2 625
梦毁少年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:42

    You can use lapply and pass indices as follows:

    ids <- seq(3, 54, by=3)
    out <- do.call(rbind, lapply(ids, function(idx) {
        t <- unlist(x[[idx]][, -1])
        c(mean(t), var(t))
    }))
    

提交回复
热议问题