This R6 class that supports creating a report card containing text, plot, table and
metadata blocks that can be appended and rendered to form a report output from a shiny app.
Lifecycle
This class is deprecated. Use teal_report class instead for new implementations.
See vignette("teal-report-class", "teal.reporter") for more information.
Methods
Method new()
Initialize a ReportCard object.
Usage
ReportCard$new()Examples
card <- ReportCard$new()
Method append_table()
Appends a table to this ReportCard.
Arguments
tableA (
data.frameorrtablesorTableTreeorElementaryTableorlisting_df) that can be coerced into a table.
Examples
card <- ReportCard$new()$append_table(iris)
Method append_html()
Appends a html content to this ReportCard.
Examples
card <- ReportCard$new()$append_html(shiny::div("HTML Content"))
Method append_plot()
Appends a plot to this ReportCard.
Method append_text()
Appends a text paragraph to this ReportCard.
Usage
ReportCard$append_text(
text,
style = c("default", "header2", "header3", "verbatim")
)Arguments
text(
character) The text content to add.style(
character(1)) the style of the paragraph.
Examples
card <- ReportCard$new()$append_text("A paragraph of default text")
Method append_rcode()
Appends an R code chunk to ReportCard.
Arguments
text(
character) TheRcode to include....Additional
rmarkdownparameters for formatting theRcode chunk.
Examples
card <- ReportCard$new()$append_rcode("2+2", echo = FALSE)
Method append_content()
Appends a generic content to this ReportCard.
Examples
card <- ReportCard$new()$append_content(code_chunk("foo <- 2"))
Method get_content()
Get all content blocks from this ReportCard.
Returns
teal_card() containing appended elements.
Examples
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2")
card$get_content()
Method get_metadata()
Get the metadata associated with ReportCard.
Examples
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2")
card$get_metadata()
Method append_metadata()
Appends metadata to this ReportCard.
Method get_name()
Get the name of the ReportCard.
Examples
ReportCard$new()$set_name("NAME")$get_name()Method set_name()
Set the name of the ReportCard.
Examples
ReportCard$new()$set_name("NAME")$get_name()Method to_list()
Convert the ReportCard to a list, including content and metadata.
Usage
ReportCard$to_list(output_dir = lifecycle::deprecated())Method from_list()
Reconstructs the ReportCard from a list representation.
Usage
ReportCard$from_list(card, output_dir = lifecycle::deprecated())Examples
library(ggplot2)
card <- ReportCard$new()$append_plot(
ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
)
#> Warning: `ReportCard$new()` was deprecated in teal.reporter 0.5.1.
#> ℹ Please use `teal_card()` instead.
#> ℹ Use teal_report class instead. See vignette('teal-report-class',
#> 'teal.reporter') for more information.
#> ℹ The deprecated feature was likely used in the R6 package.
#> Please report the issue at <https://github.com/r-lib/R6/issues>.
#> `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
library(ggplot2)
card <- ReportCard$new()$append_text("Some text")$append_plot(
ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
)$append_text("Some text")$append_metadata(key = "lm",
value = lm(Ozone ~ Solar.R, airquality))
#> `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
card$get_content()
#> $`0edf179a`
#> [1] "Some text"
#>
#> $`7706bc45`
#>
#> $`9fe76459`
#> [1] "Some text"
#>
#> attr(,"class")
#> [1] "teal_card"
#> attr(,"metadata")
#> attr(,"metadata")$lm
#>
#> Call:
#> lm(formula = Ozone ~ Solar.R, data = airquality)
#>
#> Coefficients:
#> (Intercept) Solar.R
#> 18.5987 0.1272
#>
#>
card$get_metadata()
#> $lm
#>
#> Call:
#> lm(formula = Ozone ~ Solar.R, data = airquality)
#>
#> Coefficients:
#> (Intercept) Solar.R
#> 18.5987 0.1272
#>
#>
library(ggplot2)
card <- ReportCard$new()$append_text("Some text")$append_plot(
ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
)$append_text("Some text")$append_metadata(key = "lm",
value = lm(Ozone ~ Solar.R, airquality))
#> `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
card$get_content()
#> $`2d7a3073`
#> [1] "Some text"
#>
#> $`2e3e16cd`
#>
#> $`46be58d4`
#> [1] "Some text"
#>
#> attr(,"class")
#> [1] "teal_card"
#> attr(,"metadata")
#> attr(,"metadata")$lm
#>
#> Call:
#> lm(formula = Ozone ~ Solar.R, data = airquality)
#>
#> Coefficients:
#> (Intercept) Solar.R
#> 18.5987 0.1272
#>
#>
card$to_list(tempdir())
#> Warning: The `output_dir` argument of `ReportCard$to_list()` is deprecated as of
#> teal.reporter 0.5.0.9000.
#> $`2d7a3073`
#> [1] "Some text"
#>
#> $`2e3e16cd`
#>
#> $`46be58d4`
#> [1] "Some text"
#>
#> attr(,"class")
#> [1] "teal_card"
#> attr(,"metadata")
#> attr(,"metadata")$lm
#>
#> Call:
#> lm(formula = Ozone ~ Solar.R, data = airquality)
#>
#> Coefficients:
#> (Intercept) Solar.R
#> 18.5987 0.1272
#>
#>
library(ggplot2)
card <- ReportCard$new()$append_text("Some text")$append_plot(
ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
)$append_text("Some text")$append_metadata(key = "lm",
value = lm(Ozone ~ Solar.R, airquality))
#> `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
card$get_content()
#> $b42c76bb
#> [1] "Some text"
#>
#> $ca8b9152
#>
#> $c0fdd3a3
#> [1] "Some text"
#>
#> attr(,"class")
#> [1] "teal_card"
#> attr(,"metadata")
#> attr(,"metadata")$lm
#>
#> Call:
#> lm(formula = Ozone ~ Solar.R, data = airquality)
#>
#> Coefficients:
#> (Intercept) Solar.R
#> 18.5987 0.1272
#>
#>
ReportCard$new()$from_list(card$to_list(tempdir()), tempdir())
## ------------------------------------------------
## Method `ReportCard$new`
## ------------------------------------------------
card <- ReportCard$new()
## ------------------------------------------------
## Method `ReportCard$append_table`
## ------------------------------------------------
card <- ReportCard$new()$append_table(iris)
## ------------------------------------------------
## Method `ReportCard$append_html`
## ------------------------------------------------
card <- ReportCard$new()$append_html(shiny::div("HTML Content"))
## ------------------------------------------------
## Method `ReportCard$append_text`
## ------------------------------------------------
card <- ReportCard$new()$append_text("A paragraph of default text")
## ------------------------------------------------
## Method `ReportCard$append_rcode`
## ------------------------------------------------
card <- ReportCard$new()$append_rcode("2+2", echo = FALSE)
## ------------------------------------------------
## Method `ReportCard$append_content`
## ------------------------------------------------
card <- ReportCard$new()$append_content(code_chunk("foo <- 2"))
## ------------------------------------------------
## Method `ReportCard$get_content`
## ------------------------------------------------
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2")
card$get_content()
#> $d8d6f3dd
#> [1] "Some text"
#>
#> attr(,"class")
#> [1] "teal_card"
#> attr(,"metadata")
#> attr(,"metadata")$rc
#> [1] "a <- 2 + 2"
#>
## ------------------------------------------------
## Method `ReportCard$get_metadata`
## ------------------------------------------------
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2")
card$get_metadata()
#> $rc
#> [1] "a <- 2 + 2"
#>
## ------------------------------------------------
## Method `ReportCard$get_name`
## ------------------------------------------------
ReportCard$new()$set_name("NAME")$get_name()
#> [1] "NAME"
## ------------------------------------------------
## Method `ReportCard$set_name`
## ------------------------------------------------
ReportCard$new()$set_name("NAME")$get_name()
#> [1] "NAME"