table_two_by_two: Creates tables for baseline characteristics or similar tables

Description Usage Arguments Details Value See Also Examples

View source: R/table_two_by_two.R

Description

Provide summary statistics on two or three variables. Rows consist of two variables to summaries and columns may consist of an optional stratification variable. There is also an option to print an overall column alongside the stratified summaries.

Usage

1
2
3
4
table_two_by_two(data, var, var2, var.name = NULL, var.name2 = NULL,
  var.order = NULL, var.order2 = NULL, type, strata = NULL,
  strata.names = NULL, strata.count = TRUE, overall = TRUE, count = "n",
  round = 3, messages = TRUE, zeros = FALSE)

Arguments

data

Dataset to generate table from

var

A character string naming the row variable to stratify by

var2

A character string naming the variable to summarise over

var.name

Optional. A formatted version of var

var.name2

Optional. A formatted version of var2

var.order

Optional. A vector of the values of var in the order you want to display them

var.order2

Optional. A vector of the values of var2 in the order you want to display them. Note that this creates empty rows when there are no values for a given variable.

type

A vector of the method to summarise var2

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

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_values

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)

# generate a variable to stratify by since iris only has one target
# stratification
iris$Petal.split="Short"
iris$Petal.split[iris$Petal.Length>4.3]="Long"

# build the table
table_two_by_two(iris, var="Species",var2="Sepal.Length",
var.name2="Sepal Length", type="miqr",strata="Petal.split", round=1)

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