quick.table | R Documentation |
Similarly to make.table
, this function produces summary statistics for categeorical and continuous variables and combines the results into a data frame for plain text, HTML, or LaTeX output. However, minimal input (a data frame only) is required to construct the table, as this function dynamically classifies variables as either categorical or continuous. This function is ideal for rapid summaries of data frames, but make.table
should be used instead for custom labeling and significance testing.
quick.table(dat, strat, dec, colnames, output, classlim, stripe, stripe.col)
dat |
Data frame input of all variables used for the summary table. Required. |
strat |
Character vector of names of one or more stratifying variables. Optional; defaults to no stratification. |
dec |
Integer value for number of decimal places to be printed for each summary statistic. Optional; defaults to 2. |
colnames |
Ordered vector of column names for table. Optional; defaults to levels of strata variable(s). |
output |
Choice of formatted table output: 'html', 'latex', or 'plain'. Optional; defaults to plain text printed in console. |
classlim |
Integer classification threshold for categorical and continuous variables. Optional; defaults to numeric variables with 6 or more levels being classified as continuous, and categorical otherwise. All non-numeric variables are classified as categorical. |
stripe |
HTML output only: logical indicator for whether to zebra stripe every other variable in the table. Optional; defaults to TRUE. |
stripe.col |
HTML output only: hex color code to be used for zebra striping the table. Optional; defaults to a light gray, #F7F7F7. |
Returns a table of summary statistics for specified categorical and continuous variables in the requested output format. The plain text default returns a data frame to the console.
A few miscellaneous notes:
Table output to HTML and LaTeX require the package dependencies htmlTable
and xtable
By default, the final summary table is rearranged such that the variables in the table are in the same order as in the raw data set (dat=).
If missing values occur in stratifying variables (strat=), then the observations with missings will be removed from the table, and a comment will be printed indicating the total number removed. If multiple stratifying variables are provided, look to the console for a summary of total missing observations for each variable.
For additional labeling and significance testing options, see make.table
.
Erica Wozniak
Table1
make.table
cat.var
cont.var
stat.col
out.plain
out.latex
out.html
library(survival) attach(pbc) ##Plain text example quick.table(dat=pbc, strat='sex', colnames=c('', 'Male', 'Female', 'Overall') ) ##Example with HTML options library(htmlTable) quick.table(dat=pbc, strat='sex', colnames=c('', 'Male', 'Female', 'Overall'), #See www.color-hex.com for codes output='html', stripe.col='#d0f2b0' )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.