tbl: Table Function

tblR Documentation

Table Function

Description

This function creates a contingency table from two specified variables in a dataset, with optional grouping, statistical calculations, and formatting.

Usage

tbl(
  data,
  v1,
  v2,
  groups = NULL,
  margin = "all",
  stat = "both",
  total = c("row", "col"),
  use.labels = T,
  digits = 1,
  na.label = "NA"
)

Arguments

data

A data frame containing the data to be analyzed.

v1

The first variable for the contingency table. No need to be quoted.

v2

The second variable for the contingency table. No need to be quoted.

groups

Optional grouping variable of vector of variables. No need to be quoted.

margin

Specifies the margin for proportions ('all', 'row', or 'col').

stat

The type of statistic to calculate: "n" for counts, "perc" for percentages, or "both" for both.

total

Specifies whether to include totals for rows or columns ("row", "col").

use.labels

Logical; should labels from the data be used?

digits

The number of digits to display for percentages.

na.label

The label to use for NA values.

Value

A printed table of counts and/or proportions as specified, with totals where applicable.


DiogoFerrari/edar documentation built on Dec. 1, 2024, 10:47 p.m.