[R] averaging pairs of columns in a dataframe

JonD jonathan.denniss at googlemail.com
Wed Aug 27 18:12:37 CEST 2008


That's great, thanks!

Jon



Gabor Grothendieck wrote:
> 
> Try this:
> 
> # test data
> DF <- data.frame(a = 1:9, a = 21:29, b = 31:39, b = 41:49, check.names =
> FALSE)
> 
> t(apply(DF, 1, tapply, names(DF), mean))
> 
> It gives a matrix so use as.data.frame on that if you need a data frame
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/averaging-pairs-of-columns-in-a-dataframe-tp19181319p19184350.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list