Learn R Programming

summarytools (version 0.9.2)

print.summarytools: print.summarytools

Description

Display summarytools objects in the console, in Web Browser or in RStudio's Viewer, or write content to file.

Usage

# S3 method for 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,
   escape.pipe = st_options('escape.pipe'), …)

Arguments

x

A summarytools object that was generated with freq, descr, ctable or dfSummary.

method

One of “pander”, “viewer”, “browser”, or “render”. For print(), default is “pander”; for view(), default is “viewer”. If “viewer” is used outside RStudio, “browser” will be used instead. Use “render” if function is called from an Rmd document.

file

File name to write output to. Defaults to “”.

append

Logical. When file argument is supplied, this indicates whether to append output to existing file. FALSE by default.

report.title

For html reports, this goes into the <title> tag. Defaults to NA, in which case <title> will be generic.

table.classes

Character. Additional classes to assign to output tables. All Bootstrap css classes can be used. It also allows user-defined classes (see custom.css parameter). See details section. NA by default.

bootstrap.css

Logical. Set to FALSE to omit Bootstrap css. TRUE by default. To change this default value globally, see st_options.

custom.css

Path to a user-defined .css file. Classes defined in this file can be used in the table.classes parameter. NA by default. To change this default value globally, see st_options.

silent

Hide console messages (such as ignored variables or NaN to NA transformations).

footnote

footnote in html output. When set to “default”, this is the package name and version, R version, and current date). Has no effect when method is “pander”. Set to “default”, provide your own text, or set to NA to omit. To change this default value globally, see st_options.

max.tbl.height

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. Has no effect when method is “pander”. Inf by default.

escape.pipe

Logical. Set to TRUE when using style='grid' and file argument is supplied if the intent is to generate a text file that can be converted to other formats using Pandoc. To change this default value globally, see st_options.

Additional arguments can be used to override parameters stored as attributes in the object being printed. See Details section.

Value

NULL when method="pander"; a file path (returned invisibly) when method="viewer" or method="browser". In the latter case, the file path is also passed to shell.exec so the document is opened in default Web Browser.

Details

Plain ascii and rmarkdown tables are generated via pander. See References section for a list of all available pander options.

The following additional arguments can be used to override formatting attributes stored in the object to be printed. Refer to the function's documentation for details on these arguments.

The following additional arguments can be used to override heading elements to be printed:

  • Data.frame

  • Data.frame.label

  • Variable

  • Variable.label

  • Group

  • date

  • Weights (freq & descr objects)

  • Data.type (freq objects)

  • Row.variable (ctable objects)

  • Col.variable (ctable objects)

References

RStudio Summarytools on GitHub List of pander options on GitHub Bootstrap Cascading Stylesheets

See Also

pander

Examples

Run this code
# NOT RUN {
data(tobacco)
view(dfSummary(tobacco), footnote = NA)
# }
# NOT RUN {
data(exams)
print(freq(exams$gender), style = 'rmarkdown')
print(descr(exams), headings = FALSE)

# }

Run the code above in your browser using DataLab