formatted_table: Simple Cross Table

Description Usage Arguments Examples

Description

Create a table similar to the base R function table, but instead with formatted column names and as a data.table so that it can easily be manipulated or put into an analysis.

Usage

1
formatted_table(x, ..., var_names = NULL, cross_symbol = " X ")

Arguments

x

a data.frame from which to get the columns for calculating the table.

...

one or two columns to use to calculate a simple table, or cross table. Enter the names unquoted.

var_names

custom variable names may be specified and will be used in the table title. Default NULL.

cross_symbol

symbol to use in the table title to signify the cross of two variables. Default is " X ".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Create a cross table of cyl and vs
formatted_table(mtcars, cyl, vs)

# Add custom names using the var_names parameter
formatted_table(mtcars, cyl, vs, var_names = c("Cylinders", "Engine"))

# Add a custom by option
formatted_table(mtcars, cyl, vs, cross_symbol = " by ")

# Allows for functions to be used directly as variable inputs.
formatted_table(mtcars, cyl > 6, vs, var_names = c("cyl > 6", "vs"))

jinlow/report.tools documentation built on June 2, 2019, 10:55 p.m.