我需要找到这种格式的大量数据的平均和标准偏差。我尝试使用Excel,但似乎没有一个简单的方法来转置列。我在Excel中缺少什么,还是应该使用Perl?
I've need to find the average and standard deviation of a large amount of data in this format. I tried using Excel but there doesn't appear to be an easy way to transpose the columns. What am I missing in Excel or should I just use Perl?
输入文件格式为:
0 123
0 234
0 456
1 657
1 234
1 543
希望将平均值和标准偏差分组,第一列:
Want result to group the averages and standard deviations by the values in the first column:
0 AvgOfAllZeros StdDevOfALlZeros
0 AvgOfAllZeros StdDevOfALlZeros
1 AvgOfAllOnes StdDevOfAllOnes
1 AvgOfAllOnes StdDevOfAllOnes
推荐答案这在R中很容易做到。如果你的数据在一个名为 foo 的文件中,那么这段代码将做诀窍:
This is easy to do in R. If your data is in a file called foo, then this code will do the trick:
> data <- read.table("foo") > cbind(avg=with(data, tapply(V2, V1, mean)), + stddev=with(data, tapply(V2, V1, sd))) avg stddev 0 271 169.5553 1 478 218.8630更多推荐
如何按平均和标准偏差分组?
发布评论