[R] Counting the occurence of each unique "charecter string"

ronggui 042045003 at fudan.edu.cn
Sun Nov 27 19:02:56 CET 2005


use table() to get what you want.
see ?table

======= 2005-11-28 01:49:19 ÄúÔÚÀ´ÐÅÖÐÐ´µÀ£º=======

>LS,
>  
>  I would really like to know how to count the frequency/occurrence of  chachters inside a dataset. I am working with extreemly large datasets  of forest inventory data with a large variety of different species  inside it. 
>  Each row inside the dataframe represents one individual tree and the simplified dataframe looks something like this:
>  
>  num species dbh   
>  1        sp1           30
>  2        sp1          20
>  3        sp2          30
>  4        sp1          40
>  
>  I need to be able to count the number of individuals per species, so I  need a command that will return for each unique species its occurence  inside the dataframe; 
>  
>  [sp1]     3
>  [sp2]     1
>  
>  After a long search through help.search() and the web I found very  little and any alternative like exporting the dataset to another  program(excel) is not really an option because the dataset is far to  large.
>  
>  I am using R 2.2.0 in Windows and if anyone knows a solution please help!
>  
>  Many sincere thanks in advance,
>  
>  Marco 
>  
>  
>  
>		
>---------------------------------
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

= = = = = = = = = = = = = = = = = = = =
			


 

2005-11-28

------
Deparment of Sociology
Fudan University

My new mail addres is ronggui.huang at gmail.com
Blog:http://sociology.yculblog.com




More information about the R-help mailing list