tfreq: Frequency distribution table

View source: R/tfreq.R

tfreqR Documentation

Frequency distribution table

Description

Constructs a frequency distribution table for a quantitative variable.

Usage

tfreq(data, limits = NULL, open = "right")

Arguments

data

The observations to construct the frequency distribution table.

limits

The class limits.

open

Where to leave the class limits open, left or right. Defaults to right.

Details

If class limits are not specified, the Sturges' rule is used to calculate the number of class intervals k:

k \approx 1 + 3.3 \log n

Then, the left limit for the first class interval is set to the minimum value of the data, the range r is computed and the size of the class intervals is defined by:

c \approx \frac{r}{k}

where c is rounded up with the same number of decimal places as the data.

Value

It returns a frequency distribution table with columns for class mark, absolute and relative frequencies, and cumulative absolute and relative frequencies.

Author(s)

Raúl Eyzaguirre.

Examples

# Some random data from a normal population with mean 10 and standard deviation 1
set.seed(1)
datos <- rnorm(100, 10, 1)
# Data with 3 decimal places
datos <- round(datos, 3)
# A summary of the data
summary(datos)
# Frequency table with 6 specified limits
tfreq(datos, c(7, 8, 9, 10, 11, 12, 13))
# Default method
tfreq(datos)

reyzaguirre/rhep documentation built on Dec. 2, 2024, 4:22 p.m.