[19075] in s-news-athena
[S] Question on data manipulation
daemon@ATHENA.MIT.EDU (Abd Rahman Kassim)
Wed Sep 1 02:37:16 1999
Message-Id: <01BEF486.8CCEA320.rahmank@frim.gov.my>
From: Abd Rahman Kassim <rahmank@frim.gov.my>
To: "'S-news@wubios.wustl.edu'" <S-news@wubios.wustl.edu>
Date: Wed, 1 Sep 1999 14:30:32 +0800
Dear S-plus user,
Hi! I have a question on data manipulation. I have a data set as follows:
Data file name : tree.dat
Plot X Mean.X Relative.X
1 5
1 7
1 10
1 6
2 8
2 9
2 2
2 6
where,
Mean X = mean of subject X for each plot
Relative X = relative position of subject Xi to mean X, i.e. Xi/mean X
I calculated the mean x using the aggregate function;
tree.ag<-aggregate(tree.dat[,c("X")],by=Plot,FUN=mean)
I merge the tree.dat with tree.ag to produce new file to produce file with
PLOT, X and Mean.X variables.
Mean.x<-tree.ag$x
Plot<-tree.ag$x
tree.ag<-data.frame(Plot,Mean.X)
tree.mg<-merge(tree.dat,tree.ag)
But how can I calculate the relative X value?
Kindly note that the actual data set has more than 50,000 records and
several relative value will be calculated for different main variables.
Any helps would be appreciated.
Abd Rahman
Hill Forests Silviculture
FRIM
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news