【发布时间】:2017-02-07 23:53:08
【问题描述】:
我有一个这样创建的 DF:
Sample Concentration
1 Dp10 WT 121.36
2 Dp10 WT 129.11
3 Dp10 WT 149.46
4 Dp10 141.3
5 Dp10 129.11
6 Dp10 131.02
7 Dp16 WT 0
8 Dp16 WT 134.8
9 Dp16 WT 144.5
10 Dp16 134.33
11 Dp16 129.11
12 Dp16 160.02
A = matrix(
c("Dp10 WT", "Dp10 WT", "Dp10 WT",
"Dp10", "Dp10", "Dp10",
"Dp16 WT", "Dp16 WT", "Dp16 WT",
"Dp16", "Dp16", "Dp16",
121.36, 129.11, 149.46, 141.3, 129.11, 131.02,
0, 134.8, 144.5, 134.33, 129.11, 160.02),
nrow=12,
ncol=2,
byrow = FALSE)
dimnames(A) = list(seq(1,12)
,c('Sample', 'Concentration')) # column names
DF=data.frame(A)
但计算如下所示的平均值会给我以下错误。
mm <- ddply(DF, "Sample", summarise, conc = mean(Concentration, na.rm=TRUE))
Error in attributes(out) <- attributes(col) :
'names' attribute [12] must be the same length as the vector [3]
我知道从 R 3.0 开始,数据帧的均值计算存在一些差异,但我不确定我在这里做错了什么。
【问题讨论】: