Learn R Programming

teal.reporter (version 0.6.0)

teal_card: teal_card: An S3 class for managing teal reports

Description

[Experimental]

The teal_card S3 class provides functionality to store, manage, edit, and adjust report contents. It enables users to create, manipulate, and serialize report-related data efficiently.

The teal_card() function serves two purposes:

  1. When called with a teal_report object, it acts as a getter and returns the card slot.

  2. When called with other arguments, it creates a new teal_card object from those arguments.

This function ensures that input is converted to a teal_card object. It accepts various input types and converts them appropriately.

Usage

teal_card(...)

teal_card(x) <- value

as.teal_card(x)

# S3 method for teal_card c(...)

# S3 method for teal_card [(x, i)

Value

An S3

list of class teal_card.

A teal_card object

Arguments

...

Elements from which teal_card will be combined.

x

Object to convert to teal_card

value

(teal_card) object to set in the teal_report.

i

index specifying elements to extract or replace

Details

The teal_card class supports c() and x[i] methods for combining and subsetting elements. However, these methods only function correctly when the first element is a teal_card.

See Also

code_chunk(), render(), toHTML()

Examples

Run this code
# create an empty card
report <- teal_card()

# Create a card with content
report <- teal_card(
  "## Headline",
  "This is `iris` table",
  code_chunk("print(iris)", lang = "R"),
  iris
)

# Add elements to the report
report <- c(
  report,
  list("## mtcars Table"),
  code_chunk("print(mtcars)", lang = "R"),
  mtcars
)

# Subset the report to keep only the first two elements
report[1:2]

# Replace element
report[[1]] <- "## Iris Table"

# Append element
report <- append(report, teal_card("# Awesome Report"), after = 0)
tools::toHTML(report)

if (interactive()) {
  render(report, output_format = rmarkdown::pdf_document())
}

Run the code above in your browser using DataLab