Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

binnedCounts

Binned Frequency Distributions of Numeric Variables


Description

Bins a numeric variable, as for a histogram, and reports the count and percentage in each bin. The computations are done by the hist function, but no histogram is drawn. If supplied a numeric matrix or data frame, the distribution of each column is printed.

Usage

binnedCounts(x, breaks="Sturges", round.percents=2, 
  name=deparse(substitute(x)))

Arguments

x

a numeric vector, matrix, or data frame.

breaks

specification of the breaks between bins, to be passed to the hist function.

round.percents

number of decimal places to round percentages; default is 2.

name

name for the variable; only used for vector argument x.

Value

For a numeric vector, invisibly returns the vector of counts, named with the end-points of the corresponding bins. For a matrix or data frame, invisibly returns NULL

Author(s)

See Also

Examples

with(Prestige, binnedCounts(income))
binnedCounts(Prestige[, 1:4])

RcmdrMisc

R Commander Miscellaneous Functions

v2.7-1
GPL (>= 2)
Authors
John Fox [aut, cre], Robert Muenchen [ctb], Dan Putler [ctb]
Initial release
2020-08-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.