discreteCounts: Frequency Distributions of Numeric Variables

Description Usage Arguments Value Author(s) See Also Examples

View source: R/discreteCounts.R

Description

Computes the frequency and percentage distribution of a descrete numeric variable or the distributions of the variables in a numeric matrix or data frame.

Usage

1
2
discreteCounts(x, round.percents=2, name=deparse(substitute(x)),
  max.values=min(round(2*sqrt(length(x))), round(10*log10(length(x))), 100))

Arguments

x

a discrete numeric vector, matrix, or data frame.

round.percents

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

name

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

max.values

maximum number of unique values (default is the smallest of twice the square root of the number of elements in x, 10 times the log10 of the number of elements, and 100); if exceeded, an error is reported.

Value

For a numeric vector, invisibly returns the table of counts. For a matrix or data frame, invisibly returns NULL

Author(s)

John Fox jfox@mcmaster.ca

See Also

binnedCounts

Examples

1
2
set.seed(12345) # for reproducibility
discreteCounts(data.frame(x=rpois(51, 2), y=rpois(51, 10)))

Example output

Loading required package: car
Loading required package: carData
Loading required package: sandwich
Distribution of x 
      Count Percent
0         7   13.73
1        15   29.41
2        10   19.61
3        10   19.61
4         5    9.80
5         3    5.88
6         1    1.96
Total    51  100.00

Distribution of y 
      Count Percent
4         2    3.92
5         2    3.92
6         1    1.96
7         6   11.76
8         3    5.88
9         5    9.80
10        9   17.65
11        4    7.84
12        8   15.69
13        2    3.92
14        1    1.96
15        3    5.88
16        4    7.84
18        1    1.96
Total    51   99.98

RcmdrMisc documentation built on Aug. 13, 2020, 9:06 a.m.