Re: [R] How to calculate means for multiple variables in samples with different sizes

2011-03-11 Thread Henrique Dallazuanna
Try this: aggregate(. ~ sample, x[-2], FUN = mean) On Fri, Mar 11, 2011 at 6:32 AM, Aline Santos wrote: > Hello R-helpers: > > I have data like this: > > samplereplicateheightweightage > A1.0012.00.646.00 > A2.0012.20.386.00 > A3.0012.4

Re: [R] How to calculate means for multiple variables in samples with different sizes

2011-03-11 Thread Matthew Dowle
Hi, One liners in data.table are : > x.dt[,lapply(.SD,mean),by=sample] sample replicate heightweight age [1,] A 2.0 12.2 0.503 6.00 [2,] B 1.5 12.75000 0.715 4.50 [3,] C 2.5 11.35250 0.5125000 3.75 [4,] D 2.0 14.9

Re: [R] How to calculate means for multiple variables in samples with different sizes

2011-03-11 Thread Dennis Murphy
Hi: Here are a few one-liners. Calling your data frame dd, aggregate(cbind(height, weight, age) ~ sample, data = dd, FUN = mean) sample heightweight age 1 A 12.2 0.503 6.00 2 B 12.75000 0.715 4.50 3 C 11.35250 0.5125000 3.75 4 D 14.99333 0.

Re: [R] How to calculate means for multiple variables in samples with different sizes

2011-03-11 Thread Berend Hasselman
Aline Santos wrote: > > Hello R-helpers: > > I have data like this: > > samplereplicateheightweightage > A1.0012.00.646.00 > A2.0012.20.386.00 > A3.0012.40.496.00 > B1.0012.70.654.00 > B2.0012.80.785

Re: [R] How to calculate means for multiple variables in samples with different sizes

2011-03-11 Thread jim holtman
use the package 'data.table' > x <- read.table(textConnection("samplereplicateheightweightage + A1.0012.00.646.00 + A2.0012.20.386.00 + A3.0012.40.496.00 + B1.0012.70.654.00 + B2.0012.80.785.00 + C1

[R] How to calculate means for multiple variables in samples with different sizes

2011-03-11 Thread Aline Santos
Hello R-helpers: I have data like this: samplereplicateheightweightage A1.0012.00.646.00 A2.0012.20.386.00 A3.0012.40.496.00 B1.0012.70.654.00 B2.0012.80.785.00 C1.0011.90.456.00 C2