tabfreq.leem {leem} | R Documentation |
Frequency distribution table
Description
Allows you to tabulate continuous and categorical data (quantitative or qualitative) in frequency distribution. Depending on the nature of the data, they can be grouped into class ranges or not.
Usage
## S3 method for class 'leem'
tabfreq(
data,
k = NULL,
na.rm = FALSE,
ordered = NULL,
namereduction = TRUE,
...
)
Arguments
data |
R object (data structure vector) of class leem. Use |
k |
Number of classes. Default is |
na.rm |
a logical evaluating to TRUE or FALSE indicating whether NA values should be stripped before the computation proceeds. |
ordered |
Ordered vector of the same length and elements of data object. Default is |
namereduction |
Logical argument. If |
... |
further arguments passed to or from other methods. |
Value
The result of tabfreq()
is a list. This list has two elements: table
and statistics
. The first is the data frequency table, and the second represents some useful statistics for methods of leem class.
Examples
# Example 1
library(leem)
x <- rbinom(36, 10, 0.6)
x <- new_leem(x, variable = "discrete")
tabfreq(x)
# Example 2 (Pipe operator)
rnorm(36, 100, 4) |>
new_leem(variable = "continuous") |> tabfreq()
# Example 3
x <- rbinom(36, 10, 0.6)
# Constructor (object of leem class)
x <- new_leem(x, variable = "discrete")
tab <- tabfreq(x)
# Details
tab$table
tab$statistics
# Example 3 - ordered categories ("d","a", "b", "c")
w <- rep(letters[1:4], 1:4)
w |> new_leem(variable = "discrete") |> tabfreq(ordered = c("d","a", "b", "c"))