proc_freq: SAS proc freq in R

Description Usage Arguments Value Author(s) References Examples

View source: R/proc_freq.R

Description

This function permits to reproduce the output of the SAS proc freq

Usage

1
proc_freq(variable, digits = 4)

Arguments

variable

vector on which we want to apply the function.

digits

integer that specifies the number of decimals we want to keep in the rounded figures.

Value

a R data frame of dimension [number of categories x 5]. The five columns display the following information:

Author(s)

Simon CORDE

References

Link to the author's github package repository: https://github.com/Redcart/helda

Examples

1
2
3
4
data <- iris
str(data)
result <- proc_freq(data$Species)
result

Example output

'data.frame':	150 obs. of  5 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
    Category Frequency Percentage Cumulative.Frequency Cumulative.Percentage
1     setosa        50      33.33                   50                 33.33
2 versicolor        50      33.33                  100                 66.66
3  virginica        50      33.33                  150                 99.99

helda documentation built on Jan. 6, 2021, 5:09 p.m.