如何按平均和标准偏差分组?

编程入门 行业动态 更新时间:2024-10-11 11:19:21
本文介绍了如何按平均和标准偏差分组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要找到这种格式的大量数据的平均和标准偏差。我尝试使用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

更多推荐

如何按平均和标准偏差分组?

本文发布于:2023-10-23 14:18:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521067.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:偏差   平均   标准

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!