Display summarytools objects in the console, in Web Browser or in
RStudio's Viewer, or write content to file.
Usage
# S3 method for class 'summarytools'
print(x, method = "pander", file = "",
append = FALSE, report.title = NA, table.classes = NA,
bootstrap.css = st_options('bootstrap.css'),
custom.css = st_options('custom.css'), silent = FALSE,
footnote = st_options('footnote'), max.tbl.height = Inf,
collapse = 0, escape.pipe = st_options("escape.pipe"), ...)Arguments
- x
A summarytools object, created by one of the four core functions (
freq,descr,ctable, ordfSummary).- method
Character. One of “pander”, “viewer”, “browser”, or “render”. Default value for the
print()method is “pander”; forview()/stview(), default is “viewer” if session is running in RStudio, “browser” otherwise. The main use for “render” is in R Markdown documents.- file
Character. File name to write output to. Defaults to “”.
- append
Logical. Append output to existing file (specified using the file argument).
FALSEby default.- report.title
Character. For html reports, this goes into the
<title>tag. When left toNA(default), the first line of the heading section is used (e.g.: “Data Frame Summary”).- table.classes
Character. Additional html classes to assign to output tables. Bootstrap css classes can be used. User-defined classes (see the custom.css argument) are also specified here. See details section.
NAby default.- bootstrap.css
Logical. When generating an html document, include the “includes/stylesheets/bootstrap.min.css"” file content inside a
<style type="text/css">tag in the document's<head>.TRUEby default. Can be set globally withst_options.- custom.css
Character. Path to a custom .css file. Classes defined in this must also appear in the
table.classesparameter in order to be applied to the table(s). Can be set globally withst_options.NAby default.- silent
Logical. Set to
TRUEto hide console messages (e.g.: ignored variables orNaNtoNAtransformations).FALSEby default.- footnote
Character. Text to display just after html output tables. The default value (“default”) produces a two-line footnote indicating the package's name and version, the R version, and the current date. Has no effect on ascii or markdown content. Can contain standard html tags. Set to
NAto omit. Can be set globally withst_options.- max.tbl.height
Numeric. Maximum table height in pixels allowed in rendered
dfSummary()tables. When this argument is used, results will show up in a<div>with the specified height and a scroll bar. Intended to be used in Rmd documents withmethod = "render".Infby default.- collapse
Numeric.
0by default. Set to1to makefreq()sections collapsible (when clicking on the variable name). Future versions might provide alternate collapsing options.- escape.pipe
Logical. Set to
TRUEwhenstyle="grid"andfileargument is supplied if the intent is to generate a text file that can be converted to other formats using Pandoc. Can be set globally withst_options.- ...
Additional arguments used to override attributes stored in the object, or to change formatting via
formatorpander. See Details.
Value
NULL when method="pander"; A file path returned
invisibly when method="viewer" or "browser". In the
latter case, the file path is also passed to shell.exec
(Windows) or system (*nix), causing
the document to be opened in default Web browser.
Details
Ascii and markdown tables are generated using
pander.
The following arguments can be used to override formatting attributes stored in the object:
styleround.digits(except for dfSummary objects)plain.asciijustifysplit.tablesheadingsdisplay.labelsvarnumbers(dfSummaryobjects only)labels.col(dfSummaryobjects only)graph.col(dfSummaryobjects only)valid.col(dfSummaryobjects only)na.col(dfSummaryobjects only)col.widths(dfSummaryobjects only)keep.grp.vars(dfSummaryobjects only)report.nas(freqobjects only)display.type(freqobjects only)missing(freqobjects only)
The following arguments can be used to override heading elements:
Author
Dominic Comtois, dominic.comtois@gmail.com
Examples
if (FALSE) { # \dontrun{
data(tobacco)
view(dfSummary(tobacco), footnote = NA)
} # }
data(exams)
print(freq(exams$gender), style = 'rmarkdown')
#> ### Frequencies
#> #### exams$gender
#> **Type:** Factor
#>
#> | | Freq | % Valid | % Valid Cum. | % Total | % Total Cum. |
#> |-----------:|-----:|--------:|-------------:|--------:|-------------:|
#> | **Girl** | 15 | 50.00 | 50.00 | 50.00 | 50.00 |
#> | **Boy** | 15 | 50.00 | 100.00 | 50.00 | 100.00 |
#> | **\<NA\>** | 0 | | | 0.00 | 100.00 |
#> | **Total** | 30 | 100.00 | 100.00 | 100.00 | 100.00 |
print(descr(exams), headings = FALSE)
#> Non-numerical variable(s) ignored: student, gender
#>
#> economics english french geography history math
#> ----------------- ----------- --------- -------- ----------- --------- -------
#> Mean 73.91 75.96 73.94 70.04 72.77 73.54
#> Std.Dev 8.62 7.92 10.79 10.65 10.20 9.19
#> Min 60.50 58.30 44.80 47.20 53.90 55.60
#> Q1 68.80 70.90 68.20 65.90 68.20 66.95
#> Median 71.60 74.10 73.60 68.50 72.75 73.75
#> Q3 77.00 80.60 76.70 77.80 76.50 80.35
#> Max 94.20 93.10 94.70 96.30 93.50 93.20
#> MAD 5.49 6.52 7.56 12.31 6.45 9.93
#> IQR 8.20 9.70 8.50 11.90 8.15 13.35
#> CV 0.12 0.10 0.15 0.15 0.14 0.12
#> Skewness 0.75 0.28 0.03 0.10 0.01 0.12
#> SE.Skewness 0.43 0.43 0.43 0.43 0.43 0.44
#> Kurtosis -0.42 -0.25 0.45 -0.03 -0.60 -0.58
#> N.Valid 29.00 29.00 29.00 29.00 30.00 28.00
#> N 30.00 30.00 30.00 30.00 30.00 30.00
#> Pct.Valid 96.67 96.67 96.67 96.67 100.00 93.33