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
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 TerwilligerIf 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
On 15/01/2008, at 5:13 AM, 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??hist (Hint: Look at ``Value''. Also look at the ``plot'' argument.) cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}