View source: R/data_tabulate.R
data_tabulate | R Documentation |
This function creates frequency tables of variables, including the number of levels/values as well as the distribution of raw, valid and cumulative percentages.
data_tabulate(x, ...)
## Default S3 method:
data_tabulate(x, drop_levels = FALSE, name = NULL, verbose = TRUE, ...)
## S3 method for class 'data.frame'
data_tabulate(
x,
select = NULL,
exclude = NULL,
ignore_case = FALSE,
regex = FALSE,
collapse = FALSE,
drop_levels = FALSE,
verbose = TRUE,
...
)
x |
A (grouped) data frame, a vector or factor. |
... |
not used. |
drop_levels |
Logical, if |
name |
Optional character string, which includes the name that is used for printing. |
verbose |
Toggle warnings. |
select |
Variables that will be included when performing the required tasks. Can be either
If |
exclude |
See |
ignore_case |
Logical, if |
regex |
Logical, if |
collapse |
Logical, if |
A data frame, or a list of data frames, with one frequency table as data frame per variable.
data(efc)
# vector/factor
data_tabulate(efc$c172code)
# data frame
data_tabulate(efc, c("e42dep", "c172code"))
# grouped data frame
suppressPackageStartupMessages(library(poorman, quietly = TRUE))
efc %>%
group_by(c172code) %>%
data_tabulate("e16sex")
# collapse tables
efc %>%
group_by(c172code) %>%
data_tabulate("e16sex", collapse = TRUE)
# for larger N's (> 100000), a big mark is automatically added
set.seed(123)
x <- sample(1:3, 1e6, TRUE)
data_tabulate(x, name = "Large Number")
# to remove the big mark, use "print(..., big_mark = "")"
print(data_tabulate(x), big_mark = "")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.