| ReportCard | R Documentation |
ReportCard: An R6 class for building report elementsThis 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.
For more information about the various blocks, refer to the vignette:
vignette("teal-reporter-blocks-overview", "teal.reporter").
new()Initialize a ReportCard object.
ReportCard$new()
Object of class ReportCard, invisibly.
card <- ReportCard$new()
append_table()Appends a table to this ReportCard.
ReportCard$append_table(table)
tableA (data.frame or rtables or TableTree or ElementaryTable or listing_df)
that can be coerced into a table.
self, invisibly.
card <- ReportCard$new()$append_table(iris)
append_html()Appends a html content to this ReportCard.
ReportCard$append_html(content)
contentAn object that can be rendered as a HTML content.
self, invisibly.
card <- ReportCard$new()$append_html(shiny::div("HTML Content"))
append_plot()Appends a plot to this ReportCard.
ReportCard$append_plot(plot, dim = NULL)
plot(ggplot or grob or trellis) plot object.
dim(numeric(2)) width and height in pixels.
self, invisibly.
append_text()Appends a text paragraph to this ReportCard.
ReportCard$append_text(text, style = TextBlock$new()$get_available_styles()[1])
text(character) The text content to add.
style(character(1)) the style of the paragraph. One of: default, header2, header3, verbatim.
self, invisibly.
card <- ReportCard$new()$append_text("A paragraph of default text")
append_rcode()Appends an R code chunk to ReportCard.
ReportCard$append_rcode(text, ...)
text(character) The R code to include.
...Additional rmarkdown parameters for formatting the R code chunk.
self, invisibly.
card <- ReportCard$new()$append_rcode("2+2", echo = FALSE)
append_content()Appends a generic ContentBlock to this ReportCard.
ReportCard$append_content(content)
content(ContentBlock) object.
self, invisibly.
NewpageBlock <- getFromNamespace("NewpageBlock", "teal.reporter")
card <- ReportCard$new()$append_content(NewpageBlock$new())
get_content()Get all content blocks from this ReportCard.
ReportCard$get_content()
list() list of TableBlock, TextBlock and PictureBlock.
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2")
card$get_content()
reset()Clears all content and metadata from ReportCard.
ReportCard$reset()
self, invisibly.
get_metadata()Get the metadata associated with ReportCard.
ReportCard$get_metadata()
named list list of elements.
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2")
card$get_metadata()
append_metadata()Appends metadata to this ReportCard.
ReportCard$append_metadata(key, value)
key(character(1)) string specifying the metadata key.
valuevalue associated with the metadata key.
self, invisibly.
get_name()Get the name of the ReportCard.
ReportCard$get_name()
character a card name.
ReportCard$new()$set_name("NAME")$get_name()
set_name()Set the name of the ReportCard.
ReportCard$set_name(name)
name(character(1)) a card name.
self, invisibly.
ReportCard$new()$set_name("NAME")$get_name()
to_list()Convert the ReportCard to a list, including content and metadata.
ReportCard$to_list(output_dir)
output_dir(character) with a path to the directory where files will be copied.
(named list) a ReportCard representation.
from_list()Reconstructs the ReportCard from a list representation.
ReportCard$from_list(card, output_dir)
card(named list) a ReportCard representation.
output_dir(character) with a path to the directory where a file will be copied.
self, invisibly.
clone()The objects of this class are cloneable with this method.
ReportCard$clone(deep = FALSE)
deepWhether to make a deep clone.
library(ggplot2)
card <- ReportCard$new()$append_plot(
ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
)
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))
card$get_content()
card$get_metadata()
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))
card$get_content()
card$to_list(tempdir())
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))
card$get_content()
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`
## ------------------------------------------------
NewpageBlock <- getFromNamespace("NewpageBlock", "teal.reporter")
card <- ReportCard$new()$append_content(NewpageBlock$new())
## ------------------------------------------------
## Method `ReportCard$get_content`
## ------------------------------------------------
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2")
card$get_content()
## ------------------------------------------------
## Method `ReportCard$get_metadata`
## ------------------------------------------------
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2")
card$get_metadata()
## ------------------------------------------------
## Method `ReportCard$get_name`
## ------------------------------------------------
ReportCard$new()$set_name("NAME")$get_name()
## ------------------------------------------------
## Method `ReportCard$set_name`
## ------------------------------------------------
ReportCard$new()$set_name("NAME")$get_name()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.