[R] getting the unique values and counts from a vector

Jean Eid jeaneid at chass.utoronto.ca
Fri May 20 18:25:43 CEST 2005


?table

On Fri, 20 May 2005, Wladimir Eremeev wrote:

> Dear Ravi,
> >From a vector, I want to get the unique values and the counts of these
> >unique values in the vector. For example, x<-c(2,1,2,1,4,2,1,4,1,1)
>
> try
> > hist(x,plot=FALSE,breask=unique(x))$counts
> [1] 5 3 0 0 0 2
>
>
> --
> Best regards
> Wladimir Eremeev                                     mailto:wl at eimb.ru
>
> ==========================================================================
> Research Scientist, PhD                           Leninsky Prospect 33,
> Space Monitoring & Ecoinformation Systems Sector, Moscow, Russia, 119071,
> Institute of Ecology,                             Phone: (095) 135-9972;
> Russian Academy of Sciences                       Fax: (095) 135-9972
>
> ______________________________________________
> 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
>




More information about the R-help mailing list