RON70
2008-Dec-17 11:36 UTC
[R] R function to calculate number of data points of each level
I have a dataframe with two columns : 11600 238'4 12000 218'0 12200 209'0 12600 192'0 13000 176'4 14000 145'0 15000 119'0 16000 103'0 18000 80'0 19000 68'3 20000 59'0 11600 208'1 12000 189'2 12200 180'3 There are repeatations in 1st column and I want to use this as Level. Next I want to report for each level how many data points are there, with corresponding Level number. Is there any direct R function? -- View this message in context: http://www.nabble.com/R-function-to-calculate-number-of-data-points-of-each-level-tp21051649p21051649.html Sent from the R help mailing list archive at Nabble.com.
Philipp Pagel
2008-Dec-17 13:09 UTC
[R] R function to calculate number of data points of each level
On Wed, Dec 17, 2008 at 03:36:44AM -0800, RON70 wrote:> > I have a dataframe with two columns : > > 11600 238'4 > 12000 218'0[...]> There are repeatations in 1st column and I want to use this as Level. Next I > want to report for each level how many data points are there, with > corresponding Level number. Is there any direct R function?> table(foo$V1)11600 12000 12200 12600 13000 14000 15000 16000 18000 19000 20000 2 2 2 1 1 2 2 2 2 2 1 or maybe ggregate(foo$V1, by=list(foo$V1), FUN=length) Group.1 x 1 11600 2 2 12000 2 3 12200 2 4 12600 1 5 13000 1 6 14000 2 7 15000 2 8 16000 2 9 18000 2 10 19000 2 11 20000 1 cu Philipp -- Dr. Philipp Pagel Lehrstuhl f?r Genomorientierte Bioinformatik Technische Universit?t M?nchen Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://mips.gsf.de/staff/pagel