如何找到平均模式标准偏差对于这样的数据集

时间:2017-05-01 14:27:09

标签: r mean mode

Gender   Age 
1   female 35     
2   male  34     
3   male  35     
4   male  37     
5   female  34 
6   female 35     
7   male  34     
8   male  35     
9   male  37     
10   female  34

因此,必须为两个参数计算所需的均值,模式,标准偏差。性别是男性和女性。

如果有人可以帮助我,我们非常感谢。只是试图抓住R. Im一个完整的开始

1 个答案:

答案 0 :(得分:1)

尝试以下方法:

df1 <- read.table(text = "1   female 35     
                  2   male  34     
                  3   male  35     
                  4   male  37     
                  5   female  34 
                  6   female 35     
                  7   male  34     
                  8   male  35     
                  9   male  37     
                  10   female  34")
names(df1) <- c("ID", "Gender", "Age")

tapply(df1$Age, df1$Gender, summary)

有关计算模式的添加

,请参阅here