色谱柱标准偏差R [英] Column standard deviation R

查看:132
本文介绍了色谱柱标准偏差R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道R中是否有内置函数可以计算列的标准偏差,就像colMeans为每列计算mean一样.编写自己的迷你函数(使用applysd之类的复合命令)很简单,但是我想知道是否已经可以使用某些东西,同时还能使我的代码保持整洁.

I was wondering if there was a built-in function in R that would compute the standard deviation for columns just like colMeans computes mean for every column. It would be simple enough to write my own mini function (a compound command that invokes things like apply with sd), but I was wondering if there was already something I could use whilst also keeping my code looking clean.

推荐答案

通常的想法是扫描整个函数.您有很多选择,其中一个是apply():

The general idea is to sweep the function across. You have many options, one is apply():

R> set.seed(42)
R> M <- matrix(rnorm(40),ncol=4)
R> apply(M, 2, sd)
[1] 0.835449 1.630584 1.156058 1.115269
R> 

这篇关于色谱柱标准偏差R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆