tab_tot {tabxplor}R Documentation

Add totals to a tab

Description

Add totals to a tab

Usage

tab_tot(
  tabs,
  tot = c("row", "col"),
  name = "Total",
  totcol = "last",
  data = NULL
)

Arguments

tabs

A tibble of class tab, made with tab_plain or tab_many.

tot

c("col", "row") and "both" print total rows and total columns. Set to "row" or "col" to print only one type. Set to "no" to remove all totals.

name

The names of the totals, as a character vector of length one or two. Use c("Total_row", "Total_column") to set different names for rows and cols.

totcol

"last" only prints a total column for the last factor column variable. Set to "each" to print a total column for each column variable.

data

The original database used to calculate the tab : it is only useful for mean columns (of numeric variables), in order to calculate the variances of total rows, necessary to calculate confidence intervals with tab_ci.

Value

A tibble of class tab. Total rows can then be detected using is_totrow, and total columns using is_totcol.

Examples

data <- dplyr::starwars %>% tab_prepare(sex, hair_color)

data %>%
  tab_plain(sex, hair_color) %>%
  tab_tot("col", totcol = "each")
  

[Package tabxplor version 1.1.3 Index]