Learn R Programming

arsenal (version 0.5.0)

summary.tableby: The summary method for a tableby object

Description

The summary method for a tableby object, which is a pretty rendering of a tableby object into a publication-quality results table in R-studio, and can render well in text-only.

Usage

# S3 method for tableby
summary(object, title = NULL, labelTranslations = NULL,
  digits = NA, nsmall = NA, nsmall.pct = NA, digits.test = NA,
  text = FALSE, removeBlanks = text, labelSize = 1.2, test = NA,
  test.pname = NA, pfootnote = NA, total = NA, ...)

Arguments

object

An object of class "tableby", made by the tableby function.

title

Title that will appear on the top of the header in the pretty-table rendering of the tableby object

labelTranslations

A named list (or vector) where the name is the label in the output to be replaced in the pretty rendering of tableby by the character string value for the named element of the list, e.g., list(age = "Age(Years)", meansd = "Mean(SD)"). This applies to both the statistic labels and the variables from the formula.

digits

Digits to round for significant digits of numeric, non-integer values. If digits.test is not set, digits is used for that setting.

nsmall

Minimum number of digits to the right of the decimal point to display for floating point numbers. If NA (default), it uses the value from object$control$nsmall. Allowed non-NA values are 0 <= nsmall <= 20.

nsmall.pct

Minimum number of digits to the right of the decimal point to display for percent numbers. If NA (default), it uses the value from object$control$nsmall.pct.

digits.test

Significant digits by which to round for numeric test statistic p-values, if the test was performed.

text

Logical, tell R to print the raw text version of the summary to the screen. Default is FALSE, but recommended to be TRUE for interactive R session development.

removeBlanks

Logical, remove extra blanks in the pretty rendering of the table

labelSize

Relative size difference between label column and other columns. Default is 1.2: label column ~20% bigger than other columns.

test

Logical, denoting whether the "p value" value should be printed. If NA (default), it uses the value from object$control$test.

test.pname

Title for p-value (only matters if test is TRUE; default is "p value").

pfootnote

Logical, denoting whether to add a footnote describing the test used to generate the p value. Default is FALSE.

total

Logical, denoting whether to include the "total" value. If NA (default), it uses the value from object$control$total.

...

Other arguments (not in use at this time).

Value

Results are cat'ed to stdout, and returned invisibly as a data.frame of the tableby

Details

For text-only, simply paste the summary stats together per variable, along with p-value and totals, with group variable in the header. For other formats, the paste is done into a pandoc-style markup such that it can be translated into 3 formats: latex, html, rtf. The decision of which of those it is translated to is left for run-time for whatever format into which the report is being generated.

For all interative development within R sessions, text=TRUE is recommended.

See Also

tableby.control, tableby

Examples

Run this code
# NOT RUN {
set.seed(100)
## make 3+ categories for response
nsubj <- 90
mdat <- data.frame(Response=sample(c(1,2,3),nsubj, replace=TRUE),
                   Sex=sample(c("Male", "Female"), nsubj,replace=TRUE),
                   Age=round(rnorm(nsubj,mean=40, sd=5)),
                   HtIn=round(rnorm(nsubj,mean=65,sd=5)))

## allow default summaries on RHS variables
out <- tableby(Response ~ Sex + Age + HtIn, data=mdat)
summary(out, text=TRUE)
labels(out)
labels(out) <- c(Age="Age (years)", HtIn="Height (inches)")
summary(out, labelTranslations=c(meansd="Mean-SD"), text=TRUE)

# }

Run the code above in your browser using DataLab