buildTable1: Build Table 1

Description Usage Arguments Value See Also Examples

Description

Uses buildTable1Rows to build a list of data.frames constituting table 1.

Usage

1
2
3
4
5
buildTable1(theData, theVariables, groupBy = NULL, percentFirst = TRUE,
  conductGroupTests = TRUE, combineTables = TRUE,
  stringsAsFactors = FALSE, meanDigits = getOption("digits"),
  sdDigits = getOption("digits"), freqDigits = getOption("digits"),
  statDigits = getOption("digits"), pDigits = getOption("digits"))

Arguments

theData

The data.frame containing the data for the variable.

theVariables

A vector of variables that are being reported in the table (a character vector).

groupBy

A variable (factor) used to stratify the variable being reported (see details below).

percentFirst

A boolean, if TRUE numeric variables are printed as x%(n) otherwise as n(x%).

conductGroupTests

A boolean, if TRUE group comparisons are conducted (see details below).

combineTables

A boolean, if TRUE tables are combined into 1 data frame, otherwise a list is returned with a data.frame for each variable.

stringsAsFactors

A boolean, if TRUE, any variable that is of type character will get coerced to a factor.

meanDigits

An integer indicating number of digits printed following the decimal place (this is not precision as in round, you get the number of digits you ask for, even if they are zero).

sdDigits

An integer indicating number of digits printed following the decimal place for standard deviations (this is not precision as in round, you get the number of digits you ask for, even if they are zero).

freqDigits

An integer indicating number of digits printed following the decimal place for percentages (this is not precision as in round, you get the number of digits you ask for, even if they are zero).

statDigits

An integer indicating number of digits printed following the decimal place for test statistics (this is not precision as in round, you get the number of digits you ask for, even if they are zero).

pDigits

An integer indicating number of digits printed following the decimal place for test P-Values (if numer of zeros in P is greater than pDigits the value will be "< 000...1").

Value

If combineTables is TRUE, then a single data.frame is returned. Otherwise, a list of data.frames one for each variable. All columns in the respective data frames are character vectors. For numeric variables, the column will contain the mean and standard deviation in the form(s) described above. For factor variables multiple rows are generated where columns will contain frequencies reported in percentages and counts "n" in the form described above.

If groupBy is specified then statistical tests are conducted to compare groups. For numeric variables ANOVA is used to compare group means, factors are evaluated by chi-squared test of independence.

See Also

buildTable1Rows

Examples

1
2
3
4
5
library(dplyr)
library(tidyr)
table1Tables <- buildTable1(theData = table1Dat, theVariables = c("age", "sex", "Race", "Ethnicity", "Rank"),
 groupBy="site", percentFirst = TRUE, meanDigits = 1, sdDigits = 1, freqDigits = 2, statDigits = 2, pDigits = 5)
lapply(table1Tables, print)

svannoy/table1 documentation built on May 30, 2019, 8:45 p.m.