Learn R Programming

summarytools (version 0.8.0)

print.summarytools: Print Method for Objects of Class summarytools.

Description

Display summarytools objects in the console, in Web Browser or in RStudio's Viewer, or create formatted output files.

Usage

# S3 method for summarytools
print(x, method = "pander", file = "",
   append = FALSE, report.title = NA, escape.pipe = FALSE,
   html.table.class = NA, custom.css = NA, silent = FALSE,
   footnote = "default", …)

view(x, method = "viewer", file = "", append = FALSE, report.title = NA, escape.pipe = FALSE, html.table.class = NA, custom.css = NA, silent = FALSE, footnote = "default", …)

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.

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.

html.table.class

All Bootstrap CSS classes can be used. It also allows user-defined classes (see custom.css parameter). See details section. NA by default.

custom.css

Path to a user-defined .css file. Classes defined in this file can be used in the html.table.classes parameter. NA by default.

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.

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 with default Web Browser.

Details

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

Html tables use Bootstrap Cascading Style Sheets. To add custom CSS, edit the custom.css file located in package's includes/stylesheets directory.

To print objects of class “by”, use view. This function also makes it more practical to generate html files (see examples).

Default values for html.table.attributes are as follows:

freq

'class="table table-striped table-bordered freq-table"'

ctable

'class="table table-striped table-bordered cross-table"'

descr

'class="table table-striped table-bordered desc-table"'

dfSummary

'class="table table-striped table-bordered"'

When specifying this parameter, you must also state those attributes if you want them to be applied.

The following additional arguments can be used to override formatting and other attributes stored in the object to be printed:

  • date

  • style

  • round.digits

  • justify

  • plain.ascii

  • missing

  • omit.headings

  • split.table

  • Dataframe

  • Dataframe.label

  • Variable

  • Variable.label

  • Variable.labels (descr objects only)

  • use.labels (descr objects only)

  • Data.type

  • Subset

  • Group

  • Weights

  • Row.variable (ctable objects only)

  • Col.variable (ctable objects only)

  • Row.variable.subset (ctable objects only)

  • Col.variable.subset (ctable objects only)

  • Row.variable.label (ctable objects only)

  • Col.variable.label (ctable objects only)

References

Rstudio Summarytools on Github List of pander options on Github Bootstrap Cascading Stylesheets

See Also

pander

Examples

Run this code
# NOT RUN {
  
# }
# NOT RUN {
  data(tobacco)
  view(dfSummary(tobacco))
  
# }
# NOT RUN {
  data(exams)
  print(freq(exams$gender))
  print(descr(exams), "pander", style = "grid")

# }

Run the code above in your browser using DataLab