Skip to contents

Prints 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(), or eti().

format

String, indicating the output format. Can be "markdown" "html", or "tt". format = "tt" creates a tinytable object, which is either printed as markdown or HTML table, depending on the environment. See insight::export_table() for details.

...

Arguments passed down to print_html() or print_md() (e.g., digits), or to insight::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.27|[-2.21, 2.29] |55.00% |[-0.10, 0.10] |        0%|
#> |X2        |  -0.12|[-1.99, 1.47] |50.00% |[-0.10, 0.10] |     5.56%|
#> |X3        |   0.14|[-0.96, 2.16] |60.00% |[-0.10, 0.10] |    11.11%|
#> |X4        |  -0.15|[-2.41, 1.54] |55.00% |[-0.10, 0.10] |        0%|

# gt HTML
display(result, format = "html")
Summary of Posterior Distribution
Parameter Median 95% CI pd ROPE % in ROPE
X1 -0.27 [-2.21, 2.29] 55.00% [-0.10, 0.10] 0%
X2 -0.12 [-1.99, 1.47] 50.00% [-0.10, 0.10] 5.56%
X3 0.14 [-0.96, 2.16] 60.00% [-0.10, 0.10] 11.11%
X4 -0.15 [-2.41, 1.54] 55.00% [-0.10, 0.10] 0%
# tinytable display(result, format = "tt") #> #> +-----------+--------+---------------+--------+---------------+-----------+ #> | Parameter | Median | 95% CI | pd | ROPE | % in ROPE | #> +===========+========+===============+========+===============+===========+ #> | Parameter | Median | 95% CI | pd | ROPE | % in ROPE | #> +-----------+--------+---------------+--------+---------------+-----------+ #> | X1 | -0.27 | [-2.21, 2.29] | 55.00% | [-0.10, 0.10] | 0% | #> +-----------+--------+---------------+--------+---------------+-----------+ #> | X2 | -0.12 | [-1.99, 1.47] | 50.00% | [-0.10, 0.10] | 5.56% | #> +-----------+--------+---------------+--------+---------------+-----------+ #> | X3 | 0.14 | [-0.96, 2.16] | 60.00% | [-0.10, 0.10] | 11.11% | #> +-----------+--------+---------------+--------+---------------+-----------+ #> | X4 | -0.15 | [-2.41, 1.54] | 55.00% | [-0.10, 0.10] | 0% | #> +-----------+--------+---------------+--------+---------------+-----------+ #> #> Table: Summary of Posterior Distribution # }