The summary method for a tableby
object, which is a pretty rendering of a tableby
object into a publication-quality results table in R Markdown, and can render well in text-only.
# S3 method for tableby summary( object, ..., labelTranslations = NULL, text = FALSE, title = NULL, pfootnote = FALSE, term.name = "" ) # S3 method for summary.tableby as.data.frame( x, ..., text = x$text, pfootnote = x$pfootnote, term.name = x$term.name, width = NULL, min.split = NULL, list.ok = FALSE )
object | An object of class |
---|---|
... | For |
labelTranslations | A named list (or vector) where the name is the label in the
output to be replaced in the pretty rendering by the character string
value for the named element of the list, e.g., |
text | An argument denoting how to print the summary to the screen.
Default is |
title | Title/caption for the table, defaulting to |
pfootnote | Logical, denoting whether to put footnotes describing the tests used to generate the p-values. Alternatively,
"html" to surround the outputted footnotes with |
term.name | A character vector denoting the column name for the "terms" column. It should be the same length
as the number of tables or less (it will get recycled if needed). The special value |
x | An object of class |
width | Passed to |
min.split | Passed to |
list.ok | If the object has multiple by-variables, is it okay to return a list of data.frames instead of a single data.frame?
If |
An object of class summary.tableby
Ethan Heinzen, based on code by Gregory Dougherty, Jason Sinnwell, Beth Atkinson, adapted from SAS Macros written by Paul Novotny and Ryan Lennon
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)#> #> #> | | 1 (N=25) | 2 (N=31) | 3 (N=34) | Total (N=90) | p value| #> |:------------|:---------------:|:---------------:|:---------------:|:---------------:|-------:| #> |Sex | | | | | 0.232| #> |- Female | 17 (68.0%) | 14 (45.2%) | 19 (55.9%) | 50 (55.6%) | | #> |- Male | 8 (32.0%) | 17 (54.8%) | 15 (44.1%) | 40 (44.4%) | | #> |Age | | | | | 0.547| #> |- Mean (SD) | 40.200 (4.021) | 40.161 (3.796) | 39.265 (3.671) | 39.833 (3.796) | | #> |- Range | 29.000 - 48.000 | 33.000 - 51.000 | 30.000 - 48.000 | 29.000 - 51.000 | | #> |HtIn | | | | | 0.093| #> |- Mean (SD) | 63.360 (5.322) | 66.516 (4.878) | 65.000 (5.684) | 65.067 (5.402) | | #> |- Range | 52.000 - 78.000 | 57.000 - 78.000 | 50.000 - 79.000 | 50.000 - 79.000 | | #>#> Response Sex Age HtIn #> "Response" "Sex" "Age" "HtIn"labels(out) <- c(Age="Age (years)", HtIn="Height (inches)") summary(out, stats.labels=c(meansd="Mean-SD", q1q3 = "Q1-Q3"), text=TRUE)#> #> #> | | 1 (N=25) | 2 (N=31) | 3 (N=34) | Total (N=90) | p value| #> |:---------------|:---------------:|:---------------:|:---------------:|:---------------:|-------:| #> |Sex | | | | | 0.232| #> |- Female | 17 (68.0%) | 14 (45.2%) | 19 (55.9%) | 50 (55.6%) | | #> |- Male | 8 (32.0%) | 17 (54.8%) | 15 (44.1%) | 40 (44.4%) | | #> |Age (years) | | | | | 0.547| #> |- Mean-SD | 40.200 (4.021) | 40.161 (3.796) | 39.265 (3.671) | 39.833 (3.796) | | #> |- Range | 29.000 - 48.000 | 33.000 - 51.000 | 30.000 - 48.000 | 29.000 - 51.000 | | #> |Height (inches) | | | | | 0.093| #> |- Mean-SD | 63.360 (5.322) | 66.516 (4.878) | 65.000 (5.684) | 65.067 (5.402) | | #> |- Range | 52.000 - 78.000 | 57.000 - 78.000 | 50.000 - 79.000 | 50.000 - 79.000 | | #>