tableone: Create a Table 1

Description Usage Arguments Value Examples

View source: R/tables.R

Description

This function provides a wrapper around furniture::table1 that allows it to utilize Hmisc::label as variable labels. It also automatically converts logicals to factors so logical dataframe columns are included in the table.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
tableone(
  df,
  ...,
  group = NULL,
  neg_label = "No",
  pos_label = "Yes",
  test = TRUE,
  caption = NULL,
  output = "text",
  type = c("pvalues", "simple", "condensed")
)

Arguments

df

a dataframe

...

a list of columns to be included in the table

group

a group to split the columns by

neg_label

label of the negative group

pos_label

label of the positive group

test

logical; if set to TRUE then the appropriate bivariate tests of significance are performed if splitby has more than 1 level. A message is printed when the variances of the continuous variables being tested do not meet the assumption of Homogeneity of Variance (using Breusch-Pagan Test of Heteroskedasticity) and, therefore, the argument 'var.equal = FALSE' is used in the test.

caption

when output != "text"; option is passed to knitr::kable

output

how the table is output; can be "text" or "text2" for regular console output or any of kable()'s options from knitr (e.g., "latex", "markdown", "pandoc"). A new option, 'latex2', although more limited, allows the variable name to show and has an overall better appearance.

type

what is displayed in the table; a string or a vector of strings. Two main sections can be inputted: 1. if test = TRUE, can write "pvalues", "full", or "stars" and 2. can state "simple" and/or "condense". These are discussed in more depth in the details section below.

Value

a table; the output varies based on the output parameter.

Examples

1
2
3
4
5
6
7
8
9
diamonds <- ggplot2::diamonds
diamonds$expensive <- diamonds$price > 500
Hmisc::label(diamonds$depth) <- "Depth"
Hmisc::label(diamonds$table) <- "Table"
Hmisc::label(diamonds$price) <- "Price"
Hmisc::label(diamonds$clarity) <- "Clarity"
Hmisc::label(diamonds$cut) <- "Cut"
Hmisc::label(diamonds$expensive) <- "Expensive"
diamonds %>% tableone(depth, table, price, clarity, expensive, group = cut)

dylanrussellmd/nsqipBileSpill documentation built on Dec. 20, 2021, 2:17 a.m.