Monday, November 28, 2011

R group-by aggregate()

squishes down (by rows)

> x
x gene
Scarb1[2551] -0.005680804 LHX6
Slc41a3[73512484] -0.014839480 SLC41A3
Lhx6[635] -0.001436172 LHX6
Traf7[2527] -0.013320662 TRAF7
Pcyt1b[74641319] -0.027368717 PCYT1B
E330014M11Rik*[77280559] -0.016545674 E330014M11RIK*

> aggregate(x$x, list(x$gene), mean)
Group.1 x
1 E330014M11RIK* -0.016545674
2 LHX6 -0.003558488
3 PCYT1B -0.027368717
4 SLC41A3 -0.014839480
5 TRAF7 -0.013320662

No comments: