Robert Terwilliger wrote:
> I would like to 'bin' a vector of of values (>100000 values) in much
> the same way as 'hist' does for plotting, but I just want a result
> with the bins and the frequencies.
>
> Is there a 'quick and dirty' (built-in) way to do this, or do I need
> to write some code?
>
> Many thanks,
>
> Robert Terwilliger

If you want the SAME bins as used by hist(), you can use:

   hist(Vec, breaks = ..., plot = FALSE)$counts

Another alternative is to use cut() to bin a vector and return a factor, 
upon which you can then use table() to get the counts. For example:

   table(cut(Vec, breaks = ...))

See ?hist and ?cut for more information.

HTH,

Marc Schwartz

______________________________________________
R-help@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.

Reply via email to