[R] Mean of matched data
robgriffin247
rg.rforum at hotmail.co.uk
Wed Jul 18 13:54:28 CEST 2012
Thanks,
in a way this has worked... with a slight modification to this:
narrow3<-aggregate(narrow2$value~narrow2$gene+narrow2$gender,data=narrow2,mean)
narrow4<-aggregate(narrow2$value~narrow2$gene+narrow2$gender,data=narrow2,sd)
which gives a table of the 24000 gene&gender means (narrow3) and the
standard deviations (narrow4)
which I then merge in to one df using
narrow5<-merge(narrow3,narrow4,by=c("narrow2$gene","narrow2$gender"))
colnames(narrow5)<-c("gene","gender","mean","sd")
Is there a way I can lift the mean and std.dev. values from data frame
narrow5 and paste them to the original narrow2 df? In effect... R would read
what gene and gender each row of narrow2 has & then paste in the according
mean value in to a new column. then do the same for a new sd column. each
mean/sd value would occur in the new column 80 times (there are 80
occurrences of each gene&gender combination).
rob
--
View this message in context: http://r.789695.n4.nabble.com/Mean-of-matched-data-tp4636856p4636871.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list