table_values: Creates tables for baseline characteristics or similar tables

Description Usage Arguments Details Value See Also Examples

View source: R/table_values.R

Description

Takes a dataset and returns a constructed data.frame summarising the variables of interest. This may be subset by strata and display an overall summary. A shiny user interface is provided (shiny_table_values). This runs through creating a table and prints r code to the console or a log file to rerun with an rtf wrapper to export directly to word.

Usage

1
2
3
4
table_values(data, var, var.names = NULL, var.order = list(), type,
  strata = NULL, strata.names = NULL, strata.count = TRUE,
  overall = TRUE, count = "n", round = 3, messages = TRUE,
  zeros = TRUE)

Arguments

data

Dataset to generate table from

var

A vector of the columns (in string form) to be used to generate the table from

var.names

Optional. An alternative (cleaned) list of variable names to use in the table. These may contain spaces

var.order

Optional. A list containing vectors of strings named using the column names in var. This is used to reorder count data items if the original ordering is not acceptable

type

A vector of the method to summarise the var

strata

A string of the column to used to stratify on

strata.names

Otional. A named vector of alternative strata names

strata.count

TRUE/FALSE for displaying strata counts at the top of each column

overall

TRUE/FALSE for including an overall column

count

"n","miss" or "none" providing the counts, missing values or omitting for each column for numeric variables

round

A value or vector for the number of significant figures to report the data to

messages

TRUE/FALSE report messages for missing row names in var.order

zeros

TRUE/FALSE whether to print zeros if none are found defaults to FALSE.

Details

Values labeled as "" or NA are treated as missing values and are thus listed as such. Values labeled as NaN or "NaN" are treated as not applicable and thus are ignored.

Available methods and values for Type:

"miqr" median (Q25,Q75)
"miqrr" median (Q25,Q75)[min,max]
"mrng" median (Q0,Q100)
"avsd" mean (sd)
"avci" mean (confidence interval)
"st" count
"str" count/total
"stp" count (percent)
"strp" count/total (percent)

Value

Returns a data.frame

See Also

table_two_by_two

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Data
data(iris)

# This function does not work with factors so convert to string.
iris$Species=as.character(iris$Species)

# build the table (without strata)
table_values(iris, var=c("Species","Sepal.Length","Sepal.Width","Petal.Length",
"Petal.Width"),var.names=NULL, type=c("str","miqr","miqrr","miqrr","miqrr"), round=1)

# build the table (with strata)
table_values(iris, var=c("Sepal.Length","Sepal.Width","Petal.Length","Petal.Width"),
var.names=c("Sepal Length","Sepal Width","Petal Length","Petal Width"),
strata="Species", type=c("miqr","miqr","miqr","miqr"), round=1)

csmoxford/prettyTables documentation built on May 14, 2019, 12:24 p.m.