[R] unique: factor to string

Dimitris Rizopoulos d.rizopoulos at erasmusmc.nl
Mon Jan 18 16:15:27 CET 2010


do you mean you want:

table(data$names)


I hope it helps.

Best,
Dimitris


Markus Mühlbacher wrote:
> Hi community,
> 
> I want to count the occurrence of values within a dataframe. 
> data$names is a list of many names. With namelist <- unique(data$names) I get all the existing names. But the result is a factor, not a list of strings. 
> 
> I would then like to go trough all the names in a for-loop and count their occurrence. 
> 
> How do I make this?
> 
> Best regards,
> Markus
> 
> 
> 
> 
> ______________________________________________
> 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.
> 

-- 
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014



More information about the R-help mailing list