[R] counting the number of times a string appears

Rolf Turner r.turner at auckland.ac.nz
Wed Jan 13 23:23:36 CET 2010


?table

On 14/01/2010, at 11:12 AM, Jesse Sinclair wrote:

> Hi all,
>
> I have a vector of strings and need to count the number of times a  
> string
> appears in the vector.
>
> eg:
>
>  [1] spp6  spp10 spp6  spp6  spp4  spp2  spp9  spp10 spp5  spp2   
> spp2  spp3
>  [13] spp4  spp3  spp6  spp10 spp6  spp4  spp9  spp3  spp6  spp1   
> spp10 spp8
>
>  [25] spp2  spp10 spp9  spp7  spp1  spp3  spp8  spp6  spp3  spp8   
> spp6  spp5
>
>  [37] spp5  spp9  spp3  spp1  spp4  spp5  spp9  spp3  spp3  spp5   
> spp4  spp9
>
>  [49] spp3  spp7  spp7  spp2  spp6  spp5  spp7  spp4  spp8  spp9   
> spp2  spp6
>
>  [61] spp3  spp3  spp2  spp6  spp3  spp5  spp6  spp6  spp4  spp1   
> spp1  spp1
>
>  [73] spp10 spp8  spp1  spp6  spp1  spp5  spp8  spp9  spp5  spp6  spp9
> spp10
>  [85] spp2  spp6  spp10 spp1  spp2  spp3  spp5  spp8  spp2  spp7   
> spp4  spp7
>
>  [97] spp2  spp6  spp2  spp6
>
> Is it possible to create a vector of counts for each spp1-spp10?
>
> Any help or ideas would be appreciated.
>
> Cheers,
> Jesse
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list