tab_freq: Frequency table

Description Usage Arguments Value Note See Also Examples

View source: R/tab_freq.R

Description

Creates a classical frequency distribution table.

Usage

1
tab_freq(x, nclass = "Sturges", include.lowest = TRUE, right = FALSE)

Arguments

x

a numerical vector.

nclass

a character string. Method for calculation of the number of classes from a numerical random variable.

include.lowest

logical, indicating if an <e2><80><98>x[i]<e2><80><99> equal to the lowest (or highest, for right = FALSE) <e2><80><98>breaks<e2><80><99> value should be included.

right

logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.

Value

A tibble (data frame) with five columns. First column contains class intervals, second is frequency 'f', then relative frequency 'rf', cummulative frequency 'cf' and cummulative relative frecuency 'crf', respectively.

Note

Classes with zero frequency are dropped from table. This is caused by function group_by from dplyr package, however a correction for this behavior will be implemented soon. See https://github.com/tidyverse/dplyr/pull/3492.

See Also

hist, cut.

Examples

1
2
3
4
5
6
7
8
data <- rnorm(100)
tab_freq(data)
tab_freq(data, nclass = "FD")

# Rename columns
tab_freq(data) %>%
   rename("Relative frequency" = rl,
          "Frequency" = f)

rodianf/histogramR documentation built on May 14, 2019, 7:33 a.m.