[BioC] Average based on group
Daniel Brewer
Daniel.Brewer at icr.ac.uk
Thu May 12 17:46:42 CEST 2011
Hi Fabrice,
Check out the library plyr and in particular the function ddply(),
which will do exactly what you want. There are also various in built
functions to do this kind of thing but the results aren't as sensible as
with ddply.
Dan
**************************************************************
Daniel Brewer
Institute of Cancer Research
Molecular Carcinogenesis
MUCRC
15 Cotswold Road
Sutton, Surrey SM2 5NG
United Kingdom
Tel: +44 (0) 20 8722 4109
Fax: +44 (0) 20 8722 4141
Email: daniel.brewer at icr.ac.uk
**************************************************************
>>> Fabrice Tourre <fabrice.ciup at gmail.com> 12/05/2011 16:20 >>>
Dear list,
I have dataframe, the second column is groups factor, each group has
10 items. The data as fellow.
chr10 rs9971029 71916552 0.1
chr10 rs9971029 71916553 0.4
chr10 rs9971029 71916554 0.3
chr10 rs9971029 71916555 0.9
chr10 rs9971029 71916556 1
chr10 rs9971029 71916557 2
chr10 rs9971029 71916558 4
chr10 rs9971029 71916559 0.8
chr10 rs9971029 71916560 0.9
chr10 rs9971029 71916561 0.8
chr10 rs9971030 71916726 0.6
chr10 rs9971030 71916727 0.5
chr10 rs9971030 71916728 0.4
chr10 rs9971030 71916729 0.7
chr10 rs9971030 71916730 0
chr10 rs9971030 71916731 0
chr10 rs9971030 71916732 0.6
chr10 rs9971030 71916733 0.8
chr10 rs9971030 71916734 0.9
chr10 rs9971030 71916735 1
I want to get a average of each item based on the group factor. So at
last I want to get a vector which length is 10.
The value calculated as this:
(0.1+0.6)/2
(0.4+0.5)/2
…
(0.8+1)/2
Thank you very much in advance.
_______________________________________________
Bioconductor mailing list
Bioconductor at r-project.org
https://stat.ethz.ch/mailman/listinfo/bioconductor
Search the archives:
http://news.gmane.org/gmane.science.biology.informatics.conductor
The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP.
This e-mail message is confidential and for use by the a...{{dropped:2}}
More information about the Bioconductor
mailing list