SummaryTable: Summary table from recurrence data in a data frame

Description Usage Arguments Details Author(s) Examples

Description

SummaryTable automatically creates summary tables in latex format. The function calculates the frequency and percent(optional) of each level of each categorical row variable(rowvars) for each level of each column variable(colvars).

Usage

1
2
3
4
5
SummaryTable(data,rowvars,colvar,row.names=NULL,cont.vars=NULL,percent=TRUE,output=c("latex","matrix"), reorder.columns=NULL,
cap=NULL,shortcap=NULL,lab=NULL,rnd.val=1,var.totals=FALSE,missing=TRUE,outfile="~/table1output.rtf",rtf.font.size=11,
col.widths=NULL, col.justify=('C'), header.col.justify=('C'),
rtf.row.names=FALSE, NA.string="-", space.before=NULL, space.after=NULL,
rmark.split=Inf)

Arguments

data

matrix or data frame with the row and column variables

rowvars

a character vector of quoted variable names or a numeric vector of categorical variables

colvar

a quoted variable name or a number identifying the column variable in the data

row.names

an optional character vector of row names if you want to change the displayed name for row variables. len(row.names) must equal len(rowvars)

cont.vars

a character vector of variable names, or a number vector of column indices

percent

logical indicating whether to print percentages for each row

output

a vector of outputs including one or more of latex,matrix,rtf

reorder.columns

optional character string specifying the column level to appear first in the table

cap

character string with the desired table caption

shortcap

Character string with desired short caption to use in list of tables.

lab

character string with table label

rnd.val

number of digits to round to

var.totals

logical indicating whether to print totals for each row variable

missing

logical indicating whether to create a row within each row variable for NA values

outfile

if output='rtf', a file path to save the output

rtf.font.size

if output='rtf', the size of the font in the rtf table

col.widths

if output='rtf', a vector of column widths

col.justify

if output='rtf', a vector of column alignments

header.col.justify

if output='rtf', a vector of alingments for column headers

rtf.row.names

if output='rtf', logicial indicating whether to print row names

NA.string

if output='rtf', string used to replace NA

space.before

if output='rtf', see package rtf for details

space.after

if output='rtf', see package rtf for details

Details

The core function of the table builder consists of repeated calls to a tapply statment: table <- tapply(data$count, list(rowlist[[i]],data[ ,colvar]),sum)

where data$count is a function defined variable with a 1 in each row for tabulating frequencies. rowlist[[i]] represents each row variable and data[ ,colvar] is the column variable. Currently the function does not support NA values in the column variable.

Author(s)

Dominic LaRoche

Examples

1
2
3
data(BDSSRecurrenceExample)
fr <- BDSSRecurrenceExample
SummaryTable(data=fr,rowvars=c("treated","trt2","single"),colvar="Recur",cont.vars=c("Age","meas"))

rocrat/BDSS documentation built on May 20, 2019, 5:39 p.m.