univ_quali: Univariate table for categorical data.

View source: R/tables_univariate.R

univ_qualiR Documentation

Univariate table for categorical data.

Description

Univariate table for categorical data.

Usage

univ_quali(
  x = NULL,
  totals = TRUE,
  useNA = "ifany",
  NA_string = "NA",
  freq_sorting = c(NA, "desc", "asc"),
  latex = TRUE,
  latex_placement = "ht",
  label = NULL,
  caption = NULL,
  use_comments = TRUE,
  wb = NULL,
  sheets = NULL
)

Arguments

x

a discrete quantitative variable, a character or a factor

totals

print totals?

useNA

print NA?

NA_string

character used for NA's columns title

freq_sorting

freq based sorting: can be NA (no freq based sorting) "desc" (descending) or "asc" (ascending).

latex

output the table using xtable::xtable

latex_placement

table placement for latex printing

label

latex label

caption

latex caption

use_comments

use variable comments for caption if available (and none specified as comment=)

wb

an openxlsx Workbook; if not NULL the table will be saved in the workbook too, aside printing

sheets

optional sheet names (same length as the number of tables)

Examples


wb = openxlsx::createWorkbook()
univ_quali(x = airquality$Month, wb = wb)
univ_quali(x = airquality[, c('Month')], wb = wb)
univ_quali(x = airquality[, c('Month', 'Day')], wb = wb)
univ_quali(x = airquality[, c('Month', 'Day')], latex = TRUE, wb = wb)
univ_quali(x = airquality[, c('Month', 'Day')], latex = TRUE,
           label = c('tab:airq_month', 'tab:airq_day'),
           caption = c('airquality month', 'airquality day'),
           wb = wb)
univ_quali(list('a' = rep(LETTERS[1:5],2), 'b' = rep(letters[1:5],2)),
           wb = wb)
lbmisc::wb_to_xl(wb = wb, file = '/tmp/univ_quali.xlsx')


lbraglia/lbstat documentation built on Sept. 17, 2023, 2:30 p.m.