我正在R studio中使用R。 我需要计算数据框每列的平均值。计算R中每个矩阵的平均值
cluster1 // 5 by 4 data frame
mean(cluster1) //
我:
Warning message:
In mean.default(cluster1) :
argument is not numeric or logical: returning NA
但我可以用
mean(cluster1[[1]])
获得第一列的平均值。
如何获得所有列的手段?
任何帮助,将不胜感激。
请尽量用数据 帧作品在发布问题之前找到答案。 'r专栏意味着'快速[网页搜索](https://www.google.com.au/search?q=r+column+means&oq=r+column+means)产生非常相关的第一击。其他有用的自助工具包括内置的['apropos'](http://stat.ethz.ch/R-manual/R-patched/library/utils/html/apropos.html)(例如'apropos( '')')和['findFn'](http://www.inside-r.org/packages/cran/sos/docs/findFn)放在'sos'包中。 – jbaums
另外[这个伟大的参考卡](http://cran.r-project.org/doc/contrib/Baggott-refcard-v2.pdf)。 – jbaums