Skip to content
Prev 313162 / 398506 Next

Can somebody help me with following data manipulation?

Hi,

You can also use
library(plyr)
ddply(dat,.(V1,V2),summarise,V3=mean(V3),.drop=FALSE)
#?? V1 V2??????? V3
#1?? C? 0 0.5000000
#2?? C? 1?????? NaN
#3?? G? 0 1.0000000
#4?? G? 1?????? NaN
#5?? I? 0 0.3333333
#6?? I? 1 0.4285714
#7?? O? 0 1.0000000
#8 ? O? 1 0.0000000
#9?? R? 0 0.0000000
#10? R? 1 0.6666667
#11? T? 0 0.8333333
#12? T? 1 0.5000000
A.K.



----- Original Message -----
From: Thomas Stewart <tgs.public.mail at gmail.com>
To: 
Cc: r-help <r-help at r-project.org>
Sent: Thursday, December 6, 2012 3:17 PM
Subject: Re: [R] Can somebody help me with following data manipulation?

You can directly use the tapply function.
-tgs

tapply(dat[,3],dat[,-3],mean)
On Thu, Dec 6, 2012 at 3:03 PM, Sarah Goslee <sarah.goslee at gmail.com> wrote:

            
??? [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.