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

From: Wladimir Eremeev <wl_at_eimb.ru>
Date: Sat 21 May 2005 - 02:01:53 EST


Dear Ravi,

try
> hist(x,plot=FALSE,breask=unique(x))$counts
[1] 5 3 0 0 0 2

Sorry, there is a typo above. However, it works because of it.

Correct is
> hist(x,plot=FALSE)$counts
[1] 5 3 0 0 0 2

another variant
> hist(x,plot=FALSE,breaks=c(unique(x)-1,max(unique(x))))$counts
[1] 5 3 2

--
Best regards
Wladimir Eremeev                                     mailto:wl@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@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
Received on Sat May 21 02:10:14 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:58 EST