Re: [R] remove rows in data frame by average

2013-02-22 Thread David Winsemius
tfire, TIBCO Software > wdunlap tibco.com > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >> Behalf >> Of arun >> Sent: Thursday, February 21, 2013 1:45 PM >> To: Johannes Brand >> Cc: R

Re: [R] remove rows in data frame by average

2013-02-21 Thread William Dunlap
wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of arun > Sent: Thursday, February 21, 2013 1:45 PM > To: Johannes Brand > Cc: R help > Subject: Re: [R] remove rows in data frame by ave

Re: [R] remove rows in data frame by average

2013-02-21 Thread Anthony Damico
another option that i think is easy & intuitive :) library(sqldf) mydata <- sqldf( "select Subject , Block , avg( Feature1 ) as Feature1 , avg( Feature2 ) as Feature2 , [..keep going..] , avg( Feature10 ) as Feature10 from yourdata group by Subject , Block" ) On Thu, Feb 21, 2013 at 4:45 PM,

Re: [R] remove rows in data frame by average

2013-02-21 Thread arun
Hi, May be this helps: dat1<- read.table(text=" Subject Block Trial Feature1 Feature2 1  1  1  48  40 1  1  2   62  18 1 2  1    34  43 1  2  2   51 34 1  3  1   64  14 ",sep="",header=TRUE)  res1<-do.call(rbind,lapply(split(dat1,dat1$Block),function(x) data.frame(unique(x[,1:2]),t(colMeans(x[