| binit {cgwtools} | R Documentation | 
Create histogram bins for each unique value in a sample.
Description
This is a Q&D way to create Pareto / histogram bins of a dataset when you want a separate bin for each value and don't want to deal with the 'breaks' or equivalent arguments in hist or other histogram functions in R packages. 
Usage
binit(samps,roundPrec=NULL)
Arguments
samps | 
 A vector or array of data to be binned.  | 
roundPrec | 
 The number of digits to round   | 
Details
binit sorts the input data and feeds the result to rle.  This effectively produces histogram-like results. If you want a strict Pareto order (most common first), just sort the list elements lengths and values by the magnitudes in lengths.
Value
A list containing two elements lengths: the number of items in each bin values: the data value associated with each bin
Author(s)
Carl Witthoft, carl@witthoft.com
See Also
Examples
x <- sample(1:100, 1000, rep=TRUE)
xbin <- binit(x)
plot(xbin$values,xbin$lengths, type = 'h')
# without rounding, will just be grass
x <- rnorm(1000)
 xbin <- binit(x,2)
plot(xbin$values,xbin$lengths, type = 'h')
[Package cgwtools version 4.1 Index]