问答详情
源自:4-5 R语言函数 split

sapply(s,function(x) colMeans(x[,c("Ozone","Wind","Temp")]为什么写成sapply(s, colMeans(s[,c("Ozone","Wind","Temp")]就不行呢

sapply(s,function(x) colMeans(x[,c("Ozone","Wind","Temp")]为什么写成sapply(s, colMeans(s[,c("Ozone","Wind","Temp")]就不行呢

提问者:野猴子上山 2017-04-17 20:47

个回答

  • 六弦琴
    2017-04-18 00:31:28
    已采纳

    s是列表,x是s中的数据框。对于colmeans函数,只能作用与矩阵或者数据框