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
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
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.
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
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
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
6 matches
Mail list logo