demographics: Summarize a Data Set (Demographics)

Description Usage Arguments Details Value Author(s) Examples

View source: R/demographics.R

Description

Creates a summary table of a data set in a matrix object for pretty printing via xtable.

Usage

1

Arguments

formula

A formula, with the left-hand side being empty or a group variable to summarize by. The right-hand side should include variables to summarize by; they should be either continuous variables or factors/characters.

data

A data.frame where the variables in formula come from; if not specified, variables are looked for in the parent environment.

latex

A logical variable that determines whether the resulting output will be part of a LaTeX document. Defaults to TRUE.

na.action

A function to handle missing data. See na.pass.

...

Additional arguments passed to SummarizeVar, such as decimalFactor, decimalContinuous, ContinuousSummaryFunction, and FactorSummaryFunction.

Details

This is generally used to create demographics table and used with the package xtable to print. To get proper names to display, a data.frame should be constructed such that the variable names are what the users want to be displayed. For factor variables, the user should make use of the levels and labels arguments in factor.

Value

A matrix to be used with xtable, which in turn should be used in print.xtable.

Author(s)

Vinh Nguyen

Examples

1
2
3
4
5
6
7
8
9
set.seed(1)
n <- 50
df <- data.frame(trt=sample(0:1, 2*n, replace=TRUE), x1=runif(2*n), x2=rnorm(2*n), 
   x3=sample(c("a", "b", "c"), 2*n, replace=TRUE))
demographics(~x1+x2+x3, data=df)
demographics(trt~x1+x2+x3, data=df)
demographics(~., data=df)
demographics(trt~., data=df, decimalFactor=2)
## Not run: print(xtable(Summarize(trt~., data=df)), sanitize.text.function=identity)

dustinfife/fifer documentation built on Oct. 31, 2020, 3:36 p.m.