
Print tables in different output formats
Source:R/display.R, R/print.R, R/print_html.R, and 1 more
display.describe_posterior.RdPrints tables (i.e. data frame) in different output formats.
Usage
# S3 method for class 'describe_posterior'
display(object, format = "markdown", ...)
# S3 method for class 'describe_posterior'
print(x, digits = 2, caption = "Summary of Posterior Distribution", ...)
# S3 method for class 'describe_posterior'
print_html(x, digits = 2, caption = "Summary of Posterior Distribution", ...)
# S3 method for class 'describe_posterior'
print_md(x, digits = 2, caption = "Summary of Posterior Distribution", ...)Arguments
- object, x
An object returned by one of the package's function, for example
describe_posterior(),point_estimate(), oreti().- format
String, indicating the output format. Can be
"markdown""html", or"tt".format = "tt"creates atinytableobject, which is either printed as markdown or HTML table, depending on the environment. Seeinsight::export_table()for details.- ...
Arguments passed down to
print_html()orprint_md()(e.g.,digits), or toinsight::export_table().- digits
Integer, number of digits to round the table output. Defaults to 2.
- caption
Character, caption for the table. If
NULL, no caption is added. By default, a caption is created based on the object type.
Value
If format = "markdown", the return value will be a character
vector in markdown-table format. If format = "html", an object of
class gt_tbl. If format = "tt", an object of class tinytable.
Details
display() is useful when the table-output from functions, which is
usually printed as formatted text-table to console, should be formatted for
pretty table-rendering in markdown documents, or if knitted from rmarkdown
to PDF or Word files. See
vignette
for examples.
Examples
# \donttest{
d <- data.frame(replicate(4, rnorm(20)))
result <- describe_posterior(d)
# markdown format
display(result)
#>
#>
#> Table: Summary of Posterior Distribution
#>
#> |Parameter | Median| 95% CI | pd | ROPE | % in ROPE|
#> |:---------|------:|:-------------|:------|:-------------|---------:|
#> |X1 | 0.45|[-1.85, 1.11] |55.00% |[-0.10, 0.10] | 0%|
#> |X2 | -0.18|[-1.88, 2.20] |55.00% |[-0.10, 0.10] | 16.67%|
#> |X3 | -0.37|[-1.45, 2.40] |65.00% |[-0.10, 0.10] | 5.56%|
#> |X4 | 0.38|[-1.33, 1.97] |75.00% |[-0.10, 0.10] | 16.67%|
# gt HTML
display(result, format = "html")
Summary of Posterior Distribution
Parameter
Median
95% CI
pd
ROPE
% in ROPE
# tinytable
display(result, format = "tt")
#>
#> +-----------+--------+---------------+--------+---------------+-----------+
#> | Parameter | Median | 95% CI | pd | ROPE | % in ROPE |
#> +===========+========+===============+========+===============+===========+
#> | X1 | 0.45 | [-1.85, 1.11] | 55.00% | [-0.10, 0.10] | 0% |
#> +-----------+--------+---------------+--------+---------------+-----------+
#> | X2 | -0.18 | [-1.88, 2.20] | 55.00% | [-0.10, 0.10] | 16.67% |
#> +-----------+--------+---------------+--------+---------------+-----------+
#> | X3 | -0.37 | [-1.45, 2.40] | 65.00% | [-0.10, 0.10] | 5.56% |
#> +-----------+--------+---------------+--------+---------------+-----------+
#> | X4 | 0.38 | [-1.33, 1.97] | 75.00% | [-0.10, 0.10] | 16.67% |
#> +-----------+--------+---------------+--------+---------------+-----------+
#>
#> Table: Summary of Posterior Distribution
# }