逐组子设置数据

时间:2015-05-01 11:55:47

标签: r

我想按组方式对数据框进行子集化。我想将所有数据值的子集大于组均值。我试过的代码是:

data<-read.csv("TreeData.csv")

library(plyr)
#Calculating the group means
MDBH<-ddply(data, .(PLTPA),summarise, MDBH=mean(DBH))
MDBH
dataDHT<-subset(data,DBH>MDBH)
#The subset data is incorrect, it excluded some value greater than the mean    
and included some values less than the mean.
dataDHT

我为此问题创建的数据集位于: https://www.dropbox.com/s/ejnjhg4ogk2g4rw/TreeData.csv?dl=0

提前感谢您的帮助。

0 个答案:

没有答案