[R] R function to calculate number of data points of each level

Philipp Pagel p.pagel at wzw.tum.de
Wed Dec 17 14:09:57 CET 2008


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



More information about the R-help mailing list