Title: | Reporting Tools for 'shiny' Modules |
Version: | 0.4.0 |
Date: | 2025-01-22 |
Description: | Prebuilt 'shiny' modules containing tools for the generation of 'rmarkdown' reports, supporting reproducible research and analysis. |
License: | Apache License 2.0 |
URL: | https://github.com/insightsengineering/teal.reporter, https://insightsengineering.github.io/teal.reporter/ |
BugReports: | https://github.com/insightsengineering/teal.reporter/issues |
Imports: | bslib, checkmate (≥ 2.1.0), flextable (≥ 0.9.2), grid, htmltools (≥ 0.5.4), knitr (≥ 1.42), lifecycle (≥ 0.2.0), R6, rlistings (≥ 0.2.10), rmarkdown (≥ 2.23), rtables (≥ 0.6.11), rtables.officer (≥ 0.0.2), shiny (≥ 1.6.0), shinybusy (≥ 0.3.2), shinyWidgets (≥ 0.5.1), yaml (≥ 1.1.0), zip (≥ 1.1.0) |
Suggests: | DT (≥ 0.13), formatR (≥ 1.5), formatters (≥ 0.5.10), ggplot2 (≥ 3.4.3), lattice (≥ 0.18-4), png, testthat (≥ 3.2.2), tinytex, withr (≥ 2.0.0) |
VignetteBuilder: | knitr, rmarkdown |
RdMacros: | lifecycle |
Config/Needs/verdepcheck: | rstudio/bslib, mllg/checkmate, davidgohel/flextable, rstudio/htmltools, yihui/knitr, r-lib/lifecycle, r-lib/R6, insightsengineering/rlistings, rstudio/rmarkdown, insightsengineering/rtables, insightsengineering/rtables.officer, rstudio/shiny, dreamRs/shinybusy, dreamRs/shinyWidgets, yaml=vubiostat/r-yaml, r-lib/zip, rstudio/DT, yihui/formatR, insightsengineering/formatters, tidyverse/ggplot2, deepayan/lattice, cran/png, r-lib/testthat, rstudio/tinytex, r-lib/withr |
Config/Needs/website: | insightsengineering/nesttemplate |
Encoding: | UTF-8 |
Language: | en-US |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-01-24 17:56:27 UTC; unardid |
Author: | Dawid Kaledkowski |
Maintainer: | Dawid Kaledkowski <dawid.kaledkowski@roche.com> |
Repository: | CRAN |
Date/Publication: | 2025-01-24 19:10:02 UTC |
Reporting tools for shiny
modules.
Description
A collection of tools for creating, previewing and modifying reports from shiny
modules.
Author(s)
Maintainer: Dawid Kaledkowski dawid.kaledkowski@roche.com (ORCID)
Authors:
Kartikeya Kirar kartikeya.kirar@businesspartner.roche.com (ORCID)
Marcin Kosinski marcin.kosinski.mk1@roche.com
Maciej Nasinski
Konrad Pagacz
Mahmoud Hallal mahmoud.hallal@roche.com
Other contributors:
Chendi Liao chendi.liao@roche.com [reviewer]
Dony Unardi unardid@gene.com [reviewer]
F. Hoffmann-La Roche AG [copyright holder, funder]
See Also
Useful links:
Report bugs at https://github.com/insightsengineering/teal.reporter/issues
ContentBlock
: A building block for report content
Description
This class represents a basic content unit in a report, such as text, images, or other multimedia elements. It serves as a foundation for constructing complex report structures.
Methods
Public methods
Method set_content()
Sets content of this ContentBlock
.
Usage
ContentBlock$set_content(content)
Arguments
content
(
any
) R object
Returns
self
, invisibly.
Examples
ContentBlock <- getFromNamespace("ContentBlock", "teal.reporter") block <- ContentBlock$new() block$set_content("Base64 encoded picture")
Method get_content()
Retrieves the content assigned to this block.
Usage
ContentBlock$get_content()
Returns
object stored in a private$content
field
Examples
ContentBlock <- getFromNamespace("ContentBlock", "teal.reporter") block <- ContentBlock$new() block$get_content()
Method from_list()
Create the ContentBlock
from a list.
Usage
ContentBlock$from_list(x)
Arguments
x
(
named list
) with two fieldstext
andstyle
. Use theget_available_styles
method to get all possible styles.
Returns
self
, invisibly.
Method to_list()
Convert the ContentBlock
to a list.
Usage
ContentBlock$to_list()
Returns
named list
with a text and style.
Method clone()
The objects of this class are cloneable with this method.
Usage
ContentBlock$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## Method `ContentBlock$set_content`
## ------------------------------------------------
ContentBlock <- getFromNamespace("ContentBlock", "teal.reporter")
block <- ContentBlock$new()
block$set_content("Base64 encoded picture")
## ------------------------------------------------
## Method `ContentBlock$get_content`
## ------------------------------------------------
ContentBlock <- getFromNamespace("ContentBlock", "teal.reporter")
block <- ContentBlock$new()
block$get_content()
FileBlock
Description
FileBlock
manages file-based content in a report,
ensuring appropriate handling of content files.
Super class
teal.reporter::ContentBlock
-> FileBlock
Methods
Public methods
Inherited methods
Method finalize()
Finalize the FileBlock
.
Usage
FileBlock$finalize()
Details
Removes the temporary file created in the constructor.
Method from_list()
Create the FileBlock
from a list.
The list should contain one named field, "basename"
.
Usage
FileBlock$from_list(x, output_dir)
Arguments
x
(
named list
) with one field"basename"
, a name of the file.output_dir
(
character
) with a path to the directory where a file will be copied.
Returns
self
, invisibly.
Examples
FileBlock <- getFromNamespace("FileBlock", "teal.reporter") block <- FileBlock$new() file_path <- tempfile(fileext = ".png") saveRDS(iris, file_path) block$from_list(list(basename = basename(file_path)), dirname(file_path))
Method to_list()
Convert the FileBlock
to a list.
Usage
FileBlock$to_list(output_dir)
Arguments
output_dir
(
character
) with a path to the directory where a file will be copied.
Returns
named list
with a basename
of the file.
Examples
FileBlock <- getFromNamespace("FileBlock", "teal.reporter") block <- FileBlock$new() block$to_list(tempdir())
Method clone()
The objects of this class are cloneable with this method.
Usage
FileBlock$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## Method `FileBlock$from_list`
## ------------------------------------------------
FileBlock <- getFromNamespace("FileBlock", "teal.reporter")
block <- FileBlock$new()
file_path <- tempfile(fileext = ".png")
saveRDS(iris, file_path)
block$from_list(list(basename = basename(file_path)), dirname(file_path))
## ------------------------------------------------
## Method `FileBlock$to_list`
## ------------------------------------------------
FileBlock <- getFromNamespace("FileBlock", "teal.reporter")
block <- FileBlock$new()
block$to_list(tempdir())
HTMLBlock
Description
Specialized FileBlock
for managing HTML content in reports.
It's designed to handle various HTML content, and render the report as HTML,
however htmlwidgets
objects can also be rendered to static document-ready format.
Super class
teal.reporter::ContentBlock
-> HTMLBlock
Methods
Public methods
Inherited methods
Method new()
Initialize a HTMLBlock
object.
Usage
HTMLBlock$new(content)
Arguments
content
An object that can be rendered as a HTML content assigned to this
HTMLBlock
Returns
Object of class HTMLBlock
, invisibly.
Method from_list()
Create the HTMLBlock
from a list.
Usage
HTMLBlock$from_list(x)
Arguments
x
(
named list
) with a single fieldcontent
containingshiny.tag
,shiny.tag.list
orhtmlwidget
.
Returns
self
, invisibly.
Examples
HTMLBlock <- getFromNamespace("HTMLBlock", "teal.reporter") block <- HTMLBlock$new() block$from_list(list(content = shiny::tags$div("test")))
Method to_list()
Convert the HTMLBlock
to a list.
Usage
HTMLBlock$to_list()
Returns
named list
with a text and style.
Examples
HTMLBlock <- getFromNamespace("HTMLBlock", "teal.reporter") block <- HTMLBlock$new(shiny::tags$div("test")) block$to_list()
Method clone()
The objects of this class are cloneable with this method.
Usage
HTMLBlock$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## Method `HTMLBlock$from_list`
## ------------------------------------------------
HTMLBlock <- getFromNamespace("HTMLBlock", "teal.reporter")
block <- HTMLBlock$new()
block$from_list(list(content = shiny::tags$div("test")))
## ------------------------------------------------
## Method `HTMLBlock$to_list`
## ------------------------------------------------
HTMLBlock <- getFromNamespace("HTMLBlock", "teal.reporter")
block <- HTMLBlock$new(shiny::tags$div("test"))
block$to_list()
NewpageBlock
Description
A ContentBlock
subclass that represents a page break in a report output.
Super class
teal.reporter::ContentBlock
-> NewpageBlock
Methods
Public methods
Inherited methods
Method new()
Initialize a NewpageBlock
object.
Usage
NewpageBlock$new()
Details
Returns a NewpageBlock
object with no content and the default style.
Returns
Object of class NewpageBlock
, invisibly.
Examples
NewpageBlock <- getFromNamespace("NewpageBlock", "teal.reporter") block <- NewpageBlock$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
NewpageBlock$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## Method `NewpageBlock$new`
## ------------------------------------------------
NewpageBlock <- getFromNamespace("NewpageBlock", "teal.reporter")
block <- NewpageBlock$new()
PictureBlock
Description
Specialized FileBlock
for managing picture content in reports.
It's designed to handle plots from packages such as ggplot2
, grid
, or lattice
.
It can save plots to files, set titles and specify dimensions.
Super classes
teal.reporter::ContentBlock
-> teal.reporter::FileBlock
-> PictureBlock
Methods
Public methods
Inherited methods
Method new()
Initialize a PictureBlock
object.
Usage
PictureBlock$new(plot)
Arguments
plot
(
ggplot
orgrid
) a picture in thisPictureBlock
Returns
Object of class PictureBlock
, invisibly.
Method set_content()
Sets the content of this PictureBlock
.
Usage
PictureBlock$set_content(content)
Arguments
content
(
ggplot
orgrob
ortrellis
) a picture in thisPictureBlock
Details
Raises error if argument is not a ggplot
, grob
or trellis
plot.
Returns
self
, invisibly.
Method set_title()
Sets the title of this PictureBlock
.
Usage
PictureBlock$set_title(title)
Arguments
title
(
character(1)
) a string assigned to thisPictureBlock
Details
Raises error if argument is not character(1)
.
Returns
self
, invisibly.
Examples
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter") block <- PictureBlock$new() block$set_title("Title")
Method get_title()
Get the title of this PictureBlock
.
Usage
PictureBlock$get_title()
Returns
The content of this PictureBlock
.
Examples
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter") block <- PictureBlock$new() block$get_title()
Method set_dim()
Sets the dimensions of this PictureBlock
.
Usage
PictureBlock$set_dim(dim)
Arguments
dim
(
numeric(2)
) figure dimensions (width and height) in pixels.
Returns
self
, invisibly.
Examples
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter") block <- PictureBlock$new() block$set_dim(c(800, 600))
Method get_dim()
Get PictureBlock
dimensions as a numeric vector.
Usage
PictureBlock$get_dim()
Returns
numeric
the array of 2 numeric values representing width and height in pixels.
Examples
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter") block <- PictureBlock$new() block$get_dim()
Method clone()
The objects of this class are cloneable with this method.
Usage
PictureBlock$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
library(ggplot2)
library(lattice)
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_content(ggplot(iris))
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_content(bwplot(1))
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_content(ggplotGrob(ggplot(iris)))
## ------------------------------------------------
## Method `PictureBlock$set_title`
## ------------------------------------------------
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_title("Title")
## ------------------------------------------------
## Method `PictureBlock$get_title`
## ------------------------------------------------
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$get_title()
## ------------------------------------------------
## Method `PictureBlock$set_dim`
## ------------------------------------------------
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_dim(c(800, 600))
## ------------------------------------------------
## Method `PictureBlock$get_dim`
## ------------------------------------------------
PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$get_dim()
RcodeBlock
Description
Specialized ContentBlock
designed to embed R
code in reports.
Super class
teal.reporter::ContentBlock
-> RcodeBlock
Methods
Public methods
Inherited methods
Method new()
Initialize a RcodeBlock
object.
Usage
RcodeBlock$new(content = character(0), ...)
Arguments
content
(
character(1)
orcharacter(0)
) a string assigned to thisRcodeBlock
...
any
rmarkdown
R
chunk parameter and it value.
Details
Returns a RcodeBlock
object with no content and no parameters.
Returns
Object of class RcodeBlock
, invisibly.
Examples
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter") block <- RcodeBlock$new()
Method set_content()
Sets content of this RcodeBlock
.
Usage
RcodeBlock$set_content(content)
Arguments
content
(
any
) R object
Returns
self
, invisibly.
Examples
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter") block <- RcodeBlock$new() block$set_content("a <- 1")
Method set_params()
Sets the parameters of this RcodeBlock
.
Usage
RcodeBlock$set_params(params)
Arguments
params
(
list
) anyrmarkdown
R chunk parameter and its value.
Details
Configures rmarkdown
chunk parameters for the R
code block,
influencing its rendering and execution behavior.
Returns
self
, invisibly.
Examples
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter") block <- RcodeBlock$new() block$set_params(list(echo = TRUE))
Method get_params()
Get the parameters of this RcodeBlock
.
Usage
RcodeBlock$get_params()
Returns
character
the parameters of this RcodeBlock
.
Examples
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter") block <- RcodeBlock$new() block$get_params()
Method get_available_params()
Get available array of parameters available to this RcodeBlock
.
Usage
RcodeBlock$get_available_params()
Returns
A character
array of parameters.
Examples
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter") block <- RcodeBlock$new() block$get_available_params()
Method from_list()
Create the RcodeBlock
from a list.
Usage
RcodeBlock$from_list(x)
Arguments
x
(
named list
) with two fieldstext
andparams
. Use theget_available_params
method to get all possible parameters.
Returns
self
, invisibly.
Examples
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter") block <- RcodeBlock$new() block$from_list(list(text = "sth", params = list()))
Method to_list()
Convert the RcodeBlock
to a list.
Usage
RcodeBlock$to_list()
Returns
named list
with a text and params
.
Examples
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter") block <- RcodeBlock$new() block$to_list()
Method clone()
The objects of this class are cloneable with this method.
Usage
RcodeBlock$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## Method `RcodeBlock$new`
## ------------------------------------------------
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter")
block <- RcodeBlock$new()
## ------------------------------------------------
## Method `RcodeBlock$set_content`
## ------------------------------------------------
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter")
block <- RcodeBlock$new()
block$set_content("a <- 1")
## ------------------------------------------------
## Method `RcodeBlock$set_params`
## ------------------------------------------------
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter")
block <- RcodeBlock$new()
block$set_params(list(echo = TRUE))
## ------------------------------------------------
## Method `RcodeBlock$get_params`
## ------------------------------------------------
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter")
block <- RcodeBlock$new()
block$get_params()
## ------------------------------------------------
## Method `RcodeBlock$get_available_params`
## ------------------------------------------------
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter")
block <- RcodeBlock$new()
block$get_available_params()
## ------------------------------------------------
## Method `RcodeBlock$from_list`
## ------------------------------------------------
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter")
block <- RcodeBlock$new()
block$from_list(list(text = "sth", params = list()))
## ------------------------------------------------
## Method `RcodeBlock$to_list`
## ------------------------------------------------
RcodeBlock <- getFromNamespace("RcodeBlock", "teal.reporter")
block <- RcodeBlock$new()
block$to_list()
Renderer
Description
A class for rendering reports from ContentBlock
into various formats using rmarkdown
.
It supports TextBlock
, PictureBlock
, RcodeBlock
, NewpageBlock
, and TableBlock
.
Methods
Public methods
Method new()
Initialize a Renderer
object.
Usage
Renderer$new()
Details
Creates a new instance of Renderer
with a temporary directory for storing report files.
Returns
Object of class Renderer
, invisibly.
Examples
Renderer <- getFromNamespace("Renderer", "teal.reporter") Renderer$new()
Method finalize()
Finalizes a Renderer
object.
Usage
Renderer$finalize()
Method renderRmd()
Getting the Rmd
text which could be easily rendered later.
Usage
Renderer$renderRmd( blocks, yaml_header, global_knitr = getOption("teal.reporter.global_knitr") )
Arguments
blocks
(
list
) ofTextBlock
,PictureBlock
andNewpageBlock
objects.yaml_header
(
character
) anrmarkdown
yaml
header.global_knitr
(
list
) ofknitr
parameters (passed toknitr::opts_chunk$set
) for customizing the rendering process.
Details
To access the default values for the global_knitr
parameter,
use getOption('teal.reporter.global_knitr')
. These defaults include:
-
echo = TRUE
-
tidy.opts = list(width.cutoff = 60)
-
tidy = TRUE
ifformatR
package is installed,FALSE
otherwise
Returns
Character vector constituting rmarkdown
text (yaml
header + body), ready to be rendered.
Method render()
Renders the Report
to the desired output format by compiling the rmarkdown
file.
Usage
Renderer$render( blocks, yaml_header, global_knitr = getOption("teal.reporter.global_knitr"), ... )
Arguments
blocks
(
list
) ofTextBlock
,PictureBlock
orNewpageBlock
objects.yaml_header
(
character
) anrmarkdown
yaml
header.global_knitr
(
list
) ofknitr
parameters (passed toknitr::opts_chunk$set
) for customizing the rendering process....
rmarkdown::render
arguments,input
andoutput_dir
should not be updated.
Details
To access the default values for the global_knitr
parameter,
use getOption('teal.reporter.global_knitr')
. These defaults include:
-
echo = TRUE
-
tidy.opts = list(width.cutoff = 60)
-
tidy = TRUE
ifformatR
package is installed,FALSE
otherwise
Returns
character
path to the output.
Method get_output_dir()
Get output_dir
field.
Usage
Renderer$get_output_dir()
Returns
character
a output_dir
field path.
Examples
Renderer <- getFromNamespace("Renderer", "teal.reporter")$new() Renderer$get_output_dir()
Method clone()
The objects of this class are cloneable with this method.
Usage
Renderer$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
library(yaml)
library(rtables)
library(ggplot2)
ReportCard <- getFromNamespace("ReportCard", "teal.reporter")
Reporter <- getFromNamespace("Reporter", "teal.reporter")
yaml_quoted <- getFromNamespace("yaml_quoted", "teal.reporter")
md_header <- getFromNamespace("md_header", "teal.reporter")
Renderer <- getFromNamespace("Renderer", "teal.reporter")
card1 <- ReportCard$new()
card1$append_text("Header 2 text", "header2")
card1$append_text("A paragraph of default text")
card1$append_plot(
ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
)
card2 <- ReportCard$new()
card2$append_text("Header 2 text", "header2")
card2$append_text("A paragraph of default text")
lyt <- analyze(split_rows_by(basic_table(), "Day"), "Ozone", afun = mean)
table_res2 <- build_table(lyt, airquality)
card2$append_table(table_res2)
card2$append_rcode("2+2", echo = FALSE)
reporter <- Reporter$new()
reporter$append_cards(list(card1, card2))
yaml_l <- list(
author = yaml_quoted("NEST"),
title = yaml_quoted("Report"),
date = yaml_quoted("07/04/2019"),
output = list(html_document = list(toc = FALSE))
)
yaml_header <- md_header(as.yaml(yaml_l))
result_path <- Renderer$new()$renderRmd(reporter$get_blocks(), yaml_header)
library(yaml)
library(ggplot2)
ReportCard <- getFromNamespace("ReportCard", "teal.reporter")
Reporter <- getFromNamespace("Reporter", "teal.reporter")
yaml_quoted <- getFromNamespace("yaml_quoted", "teal.reporter")
md_header <- getFromNamespace("md_header", "teal.reporter")
Renderer <- getFromNamespace("Renderer", "teal.reporter")
card1 <- ReportCard$new()
card1$append_text("Header 2 text", "header2")
card1$append_text("A paragraph of default text")
card1$append_plot(
ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
)
card2 <- ReportCard$new()
card2$append_text("Header 2 text", "header2")
card2$append_text("A paragraph of default text")
lyt <- analyze(split_rows_by(basic_table(), "Day"), "Ozone", afun = mean)
table_res2 <- build_table(lyt, airquality)
card2$append_table(table_res2)
card2$append_rcode("2+2", echo = FALSE)
reporter <- Reporter$new()
reporter$append_cards(list(card1, card2))
yaml_l <- list(
author = yaml_quoted("NEST"),
title = yaml_quoted("Report"),
date = yaml_quoted("07/04/2019"),
output = list(html_document = list(toc = FALSE))
)
yaml_header <- md_header(as.yaml(yaml_l))
result_path <- Renderer$new()$render(reporter$get_blocks(), yaml_header)
## ------------------------------------------------
## Method `Renderer$new`
## ------------------------------------------------
Renderer <- getFromNamespace("Renderer", "teal.reporter")
Renderer$new()
## ------------------------------------------------
## Method `Renderer$get_output_dir`
## ------------------------------------------------
Renderer <- getFromNamespace("Renderer", "teal.reporter")$new()
Renderer$get_output_dir()
ReportCard
: An R6
class for building report elements
Description
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.
For more information about the various blocks, refer to the vignette:
vignette("teal-reporter-blocks-overview", "teal.reporter")
.
Methods
Public methods
Method new()
Initialize a ReportCard
object.
Usage
ReportCard$new()
Returns
Object of class ReportCard
, invisibly.
Examples
card <- ReportCard$new()
Method append_table()
Appends a table to this ReportCard
.
Usage
ReportCard$append_table(table)
Arguments
table
A (
data.frame
orrtables
orTableTree
orElementaryTable
orlisting_df
) that can be coerced into a table.
Returns
self
, invisibly.
Examples
card <- ReportCard$new()$append_table(iris)
Method append_html()
Appends a html content to this ReportCard
.
Usage
ReportCard$append_html(content)
Arguments
content
An object that can be rendered as a HTML content.
Returns
self
, invisibly.
Examples
card <- ReportCard$new()$append_html(shiny::div("HTML Content"))
Method append_plot()
Appends a plot to this ReportCard
.
Usage
ReportCard$append_plot(plot, dim = NULL)
Arguments
plot
(
ggplot
orgrob
ortrellis
) plot object.dim
(
numeric(2)
) width and height in pixels.
Returns
self
, invisibly.
Method append_text()
Appends a text paragraph to this ReportCard
.
Usage
ReportCard$append_text(text, style = TextBlock$new()$get_available_styles()[1])
Arguments
text
(
character
) The text content to add.style
(
character(1)
) the style of the paragraph. One of: default, header2, header3, verbatim.
Returns
self
, invisibly.
Examples
card <- ReportCard$new()$append_text("A paragraph of default text")
Method append_rcode()
Appends an R
code chunk to ReportCard
.
Usage
ReportCard$append_rcode(text, ...)
Arguments
text
(
character
) TheR
code to include....
Additional
rmarkdown
parameters for formatting theR
code chunk.
Returns
self
, invisibly.
Examples
card <- ReportCard$new()$append_rcode("2+2", echo = FALSE)
Method append_content()
Appends a generic ContentBlock
to this ReportCard
.
Usage
ReportCard$append_content(content)
Arguments
content
(
ContentBlock
) object.
Returns
self
, invisibly.
Examples
NewpageBlock <- getFromNamespace("NewpageBlock", "teal.reporter") card <- ReportCard$new()$append_content(NewpageBlock$new())
Method get_content()
Get all content blocks from this ReportCard
.
Usage
ReportCard$get_content()
Returns
list()
list of TableBlock
, TextBlock
and PictureBlock
.
Examples
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2") card$get_content()
Method reset()
Clears all content and metadata from ReportCard
.
Usage
ReportCard$reset()
Returns
self
, invisibly.
Method get_metadata()
Get the metadata associated with ReportCard
.
Usage
ReportCard$get_metadata()
Returns
named list
list of elements.
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
.
Usage
ReportCard$append_metadata(key, value)
Arguments
key
(
character(1)
) string specifying the metadata key.value
value associated with the metadata key.
Returns
self
, invisibly.
Method get_name()
Get the name of the ReportCard
.
Usage
ReportCard$get_name()
Returns
character
a card name.
Examples
ReportCard$new()$set_name("NAME")$get_name()
Method set_name()
Set the name of the ReportCard
.
Usage
ReportCard$set_name(name)
Arguments
name
(
character(1)
) a card name.
Returns
self
, invisibly.
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)
Arguments
output_dir
(
character
) with a path to the directory where files will be copied.
Returns
(named list
) a ReportCard
representation.
Method from_list()
Reconstructs the ReportCard
from a list representation.
Usage
ReportCard$from_list(card, output_dir)
Arguments
card
(
named list
) aReportCard
representation.output_dir
(
character
) with a path to the directory where a file will be copied.
Returns
self
, invisibly.
Method clone()
The objects of this class are cloneable with this method.
Usage
ReportCard$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
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()
Reporter
: An R6
class for managing report cards
Description
This R6
class is designed to store and manage report cards,
facilitating the creation, manipulation, and serialization of report-related data.
Methods
Public methods
Method new()
Initialize a Reporter
object.
Usage
Reporter$new()
Returns
Object of class Reporter
, invisibly.
Examples
reporter <- Reporter$new()
Method append_cards()
Append one or more ReportCard
objects to the Reporter
.
Usage
Reporter$append_cards(cards)
Arguments
cards
(
ReportCard
) or a list of such objects
Returns
self
, invisibly.
Method get_cards()
Retrieves all ReportCard
objects contained in the Reporter
.
Usage
Reporter$get_cards()
Returns
A (list
) of ReportCard
objects.
Method get_blocks()
Compiles and returns all content blocks from the ReportCard
in the Reporter
.
Usage
Reporter$get_blocks(sep = NewpageBlock$new())
Arguments
sep
An optional separator to insert between each content block. Default is a
NewpageBlock$new()
object.
Returns
list()
list of TableBlock
, TextBlock
, PictureBlock
and NewpageBlock
.
Method reset()
Resets the Reporter
, removing all ReportCard
objects and metadata.
Usage
Reporter$reset()
Returns
self
, invisibly.
Method remove_cards()
Removes specific ReportCard
objects from the Reporter
by their indices.
Usage
Reporter$remove_cards(ids = NULL)
Arguments
ids
(
integer(id)
) the indexes of cards
Returns
self
, invisibly.
Method swap_cards()
Swaps the positions of two ReportCard
objects within the Reporter
.
Usage
Reporter$swap_cards(start, end)
Arguments
start
(
integer
) the index of the first cardend
(
integer
) the index of the second card
Returns
self
, invisibly.
Method get_reactive_add_card()
Gets the current value of the reactive variable for adding cards.
Usage
Reporter$get_reactive_add_card()
Returns
reactive_add_card
current numeric
value of the reactive variable.
Examples
library(shiny) isolate(Reporter$new()$get_reactive_add_card())
Method get_metadata()
Get the metadata associated with this Reporter
.
Usage
Reporter$get_metadata()
Returns
named list
of metadata to be appended.
Examples
reporter <- Reporter$new()$append_metadata(list(sth = "sth")) reporter$get_metadata()
Method append_metadata()
Appends metadata to this Reporter
.
Usage
Reporter$append_metadata(meta)
Arguments
meta
(
named list
) of metadata to be appended.
Returns
self
, invisibly.
Examples
reporter <- Reporter$new()$append_metadata(list(sth = "sth")) reporter$get_metadata()
Method from_reporter()
Reinitializes a Reporter
instance by copying the report cards and metadata from another Reporter
.
Usage
Reporter$from_reporter(reporter)
Arguments
reporter
(
Reporter
) instance to copy from.
Returns
invisibly self
Examples
reporter <- Reporter$new() reporter$from_reporter(reporter)
Method to_list()
Convert a Reporter
to a list and transfer any associated files to specified directory.
Usage
Reporter$to_list(output_dir)
Arguments
output_dir
(
character(1)
) a path to the directory where files will be copied.
Returns
named list
representing the Reporter
instance, including version information,
metadata, and report cards.
Examples
reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "testdir") dir.create(tmp_dir) reporter$to_list(tmp_dir)
Method from_list()
Reinitializes a Reporter
from a list representation and associated files in a specified directory.
Usage
Reporter$from_list(rlist, output_dir)
Arguments
rlist
(
named list
) representing aReporter
instance.output_dir
(
character(1)
) a path to the directory from which files will be copied.
Returns
self
, invisibly.
Examples
reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "testdir") unlink(tmp_dir, recursive = TRUE) dir.create(tmp_dir) reporter$from_list(reporter$to_list(tmp_dir), tmp_dir)
Method to_jsondir()
Serializes the Reporter
to a JSON
file and copies any associated files to a specified directory.
Usage
Reporter$to_jsondir(output_dir)
Arguments
output_dir
(
character(1)
) a path to the directory where files will be copied,JSON
and statics.
Returns
output_dir
argument.
Examples
reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "jsondir") dir.create(tmp_dir) reporter$to_jsondir(tmp_dir)
Method from_jsondir()
Reinitializes a Reporter
from a JSON
file and files in a specified directory.
Usage
Reporter$from_jsondir(output_dir)
Arguments
output_dir
(
character(1)
) a path to the directory with files,JSON
and statics.
Returns
self
, invisibly.
Examples
reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "jsondir") dir.create(tmp_dir) unlink(list.files(tmp_dir, recursive = TRUE)) reporter$to_jsondir(tmp_dir) reporter$from_jsondir(tmp_dir)
Method set_id()
Set the Reporter
id
Optionally add id to a Reporter
which will be compared when it is rebuilt from a list.
The id is added to the downloaded file name.
Usage
Reporter$set_id(id)
Arguments
id
(
character(1)
) a Report id.
Returns
self
, invisibly.
Method get_id()
Get the Reporter
id
Usage
Reporter$get_id()
Returns
character(1)
the Reporter
id.
Method clone()
The objects of this class are cloneable with this method.
Usage
Reporter$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Note
The function has to be used in the shiny reactive context.
if Report has an id when converting to JSON then It will be compared to the currently available one.
if Report has an id when converting to JSON then It will be compared to the currently available one.
Examples
library(ggplot2)
library(rtables)
card1 <- ReportCard$new()
card1$append_text("Header 2 text", "header2")
card1$append_text("A paragraph of default text")
card1$append_plot(
ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
)
card2 <- ReportCard$new()
card2$append_text("Header 2 text", "header2")
card2$append_text("A paragraph of default text")
lyt <- analyze(split_rows_by(basic_table(), "Day"), "Ozone", afun = mean)
table_res2 <- build_table(lyt, airquality)
card2$append_table(table_res2)
reporter <- Reporter$new()
reporter$append_cards(list(card1, card2))
library(ggplot2)
library(rtables)
card1 <- ReportCard$new()
card1$append_text("Header 2 text", "header2")
card1$append_text("A paragraph of default text")
card1$append_plot(
ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
)
card2 <- ReportCard$new()
card2$append_text("Header 2 text", "header2")
card2$append_text("A paragraph of default text")
lyt <- analyze(split_rows_by(basic_table(), "Day"), "Ozone", afun = mean)
table_res2 <- build_table(lyt, airquality)
card2$append_table(table_res2)
reporter <- Reporter$new()
reporter$append_cards(list(card1, card2))
reporter$get_cards()
library(ggplot2)
library(rtables)
card1 <- ReportCard$new()
card1$append_text("Header 2 text", "header2")
card1$append_text("A paragraph of default text")
card1$append_plot(
ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
)
card2 <- ReportCard$new()
card2$append_text("Header 2 text", "header2")
card2$append_text("A paragraph of default text")
lyt <- analyze(split_rows_by(basic_table(), "Day"), "Ozone", afun = mean)
table_res2 <- build_table(lyt, airquality)
card2$append_table(table_res2)
reporter <- Reporter$new()
reporter$append_cards(list(card1, card2))
reporter$get_blocks()
## ------------------------------------------------
## Method `Reporter$new`
## ------------------------------------------------
reporter <- Reporter$new()
## ------------------------------------------------
## Method `Reporter$get_reactive_add_card`
## ------------------------------------------------
library(shiny)
isolate(Reporter$new()$get_reactive_add_card())
## ------------------------------------------------
## Method `Reporter$get_metadata`
## ------------------------------------------------
reporter <- Reporter$new()$append_metadata(list(sth = "sth"))
reporter$get_metadata()
## ------------------------------------------------
## Method `Reporter$append_metadata`
## ------------------------------------------------
reporter <- Reporter$new()$append_metadata(list(sth = "sth"))
reporter$get_metadata()
## ------------------------------------------------
## Method `Reporter$from_reporter`
## ------------------------------------------------
reporter <- Reporter$new()
reporter$from_reporter(reporter)
## ------------------------------------------------
## Method `Reporter$to_list`
## ------------------------------------------------
reporter <- Reporter$new()
tmp_dir <- file.path(tempdir(), "testdir")
dir.create(tmp_dir)
reporter$to_list(tmp_dir)
## ------------------------------------------------
## Method `Reporter$from_list`
## ------------------------------------------------
reporter <- Reporter$new()
tmp_dir <- file.path(tempdir(), "testdir")
unlink(tmp_dir, recursive = TRUE)
dir.create(tmp_dir)
reporter$from_list(reporter$to_list(tmp_dir), tmp_dir)
## ------------------------------------------------
## Method `Reporter$to_jsondir`
## ------------------------------------------------
reporter <- Reporter$new()
tmp_dir <- file.path(tempdir(), "jsondir")
dir.create(tmp_dir)
reporter$to_jsondir(tmp_dir)
## ------------------------------------------------
## Method `Reporter$from_jsondir`
## ------------------------------------------------
reporter <- Reporter$new()
tmp_dir <- file.path(tempdir(), "jsondir")
dir.create(tmp_dir)
unlink(list.files(tmp_dir, recursive = TRUE))
reporter$to_jsondir(tmp_dir)
reporter$from_jsondir(tmp_dir)
TableBlock
Description
Specialized FileBlock
for managing table content in reports.
It's designed to handle various table formats, converting them into a consistent,
document-ready format (e.g., flextable
) for inclusion in reports.
Super classes
teal.reporter::ContentBlock
-> teal.reporter::FileBlock
-> TableBlock
Methods
Public methods
Inherited methods
Method new()
Initialize a TableBlock
object.
Usage
TableBlock$new(table)
Arguments
table
(
data.frame
orrtables
orTableTree
orElementaryTable
orlisting_df
) a table assigned to thisTableBlock
Returns
Object of class TableBlock
, invisibly.
Method set_content()
Sets content of this TableBlock
.
Usage
TableBlock$set_content(content)
Arguments
content
(
data.frame
orrtables
orTableTree
orElementaryTable
orlisting_df
) a table assigned to thisTableBlock
Details
Raises error if argument is not a table-like object.
Returns
self
, invisibly.
Examples
TableBlock <- getFromNamespace("TableBlock", "teal.reporter") block <- TableBlock$new() block$set_content(iris)
Method clone()
The objects of this class are cloneable with this method.
Usage
TableBlock$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## Method `TableBlock$set_content`
## ------------------------------------------------
TableBlock <- getFromNamespace("TableBlock", "teal.reporter")
block <- TableBlock$new()
block$set_content(iris)
TextBlock
Description
Specialized ContentBlock
for embedding styled text within reports.
It supports multiple styling options to accommodate various text roles,
such as headers or verbatim text, in the report content.
Super class
teal.reporter::ContentBlock
-> TextBlock
Methods
Public methods
Inherited methods
Method new()
Initialize a TextBlock
object.
Usage
TextBlock$new(content = character(0), style = private$styles[1])
Arguments
content
(
character
) a string assigned to thisTextBlock
style
(
character(1)
) one of:"default"
,"header2"
,"header3"
"verbatim"
Details
Constructs a TextBlock
object with no content and the default style.
Returns
Object of class TextBlock
, invisibly.
Examples
TextBlock <- getFromNamespace("TextBlock", "teal.reporter") block <- TextBlock$new()
Method set_content()
Sets content of this TextBlock
.
Usage
TextBlock$set_content(content)
Arguments
content
(
any
) R object
Returns
self
, invisibly.
Examples
ContentBlock <- getFromNamespace("ContentBlock", "teal.reporter") block <- ContentBlock$new() block$set_content("Base64 encoded picture")
Method set_style()
Sets the style of this TextBlock
.
Usage
TextBlock$set_style(style)
Arguments
style
(
character(1)
) one of:"default"
,"header2"
,"header3"
"verbatim"
Details
The style has bearing on the rendering of this block.
Returns
self
, invisibly.
Examples
TextBlock <- getFromNamespace("TextBlock", "teal.reporter") block <- TextBlock$new() block$set_style("header2")
Method get_style()
Get the style of this TextBlock
.
Usage
TextBlock$get_style()
Returns
character(1)
the style of this TextBlock
.
Examples
TextBlock <- getFromNamespace("TextBlock", "teal.reporter") block <- TextBlock$new() block$get_style()
Method get_available_styles()
Get available an array of styles available to this TextBlock
.
Usage
TextBlock$get_available_styles()
Returns
A character
array of styles.
Examples
TextBlock <- getFromNamespace("TextBlock", "teal.reporter") block <- TextBlock$new() block$get_available_styles()
Method from_list()
Create the TextBlock
from a list.
Usage
TextBlock$from_list(x)
Arguments
x
(
named list
) with two fieldstext
andstyle
. Use theget_available_styles
method to get all possible styles.
Returns
self
, invisibly.
Examples
TextBlock <- getFromNamespace("TextBlock", "teal.reporter") block <- TextBlock$new() block$from_list(list(text = "sth", style = "default"))
Method to_list()
Convert the TextBlock
to a list.
Usage
TextBlock$to_list()
Returns
named list
with a text and style.
Examples
TextBlock <- getFromNamespace("TextBlock", "teal.reporter") block <- TextBlock$new() block$to_list()
Method clone()
The objects of this class are cloneable with this method.
Usage
TextBlock$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## Method `TextBlock$new`
## ------------------------------------------------
TextBlock <- getFromNamespace("TextBlock", "teal.reporter")
block <- TextBlock$new()
## ------------------------------------------------
## Method `TextBlock$set_content`
## ------------------------------------------------
ContentBlock <- getFromNamespace("ContentBlock", "teal.reporter")
block <- ContentBlock$new()
block$set_content("Base64 encoded picture")
## ------------------------------------------------
## Method `TextBlock$set_style`
## ------------------------------------------------
TextBlock <- getFromNamespace("TextBlock", "teal.reporter")
block <- TextBlock$new()
block$set_style("header2")
## ------------------------------------------------
## Method `TextBlock$get_style`
## ------------------------------------------------
TextBlock <- getFromNamespace("TextBlock", "teal.reporter")
block <- TextBlock$new()
block$get_style()
## ------------------------------------------------
## Method `TextBlock$get_available_styles`
## ------------------------------------------------
TextBlock <- getFromNamespace("TextBlock", "teal.reporter")
block <- TextBlock$new()
block$get_available_styles()
## ------------------------------------------------
## Method `TextBlock$from_list`
## ------------------------------------------------
TextBlock <- getFromNamespace("TextBlock", "teal.reporter")
block <- TextBlock$new()
block$from_list(list(text = "sth", style = "default"))
## ------------------------------------------------
## Method `TextBlock$to_list`
## ------------------------------------------------
TextBlock <- getFromNamespace("TextBlock", "teal.reporter")
block <- TextBlock$new()
block$to_list()
Add card button module
Description
Provides a button to add views/cards to a report.
For more details see the vignette: vignette("simpleReporter", "teal.reporter")
.
Usage
add_card_button_ui(id)
add_card_button_srv(id, reporter, card_fun)
Arguments
id |
( |
reporter |
( |
card_fun |
( |
Details
The card_fun
function is designed to create a new ReportCard
instance and optionally customize it:
The
card
parameter allows for specifying a custom or defaultReportCard
instance.Use the
comment
parameter to add a comment to the card viacard$append_text()
- ifcard_fun
does not have thecomment
parameter, thencomment
fromAdd Card UI
module will be added at the end of the content of the card.The
label
parameter enables customization of the card's name and its content throughcard$append_text()
- ifcard_fun
does not have thelabel
parameter, then card name will be set to the name passed inAdd Card UI
module, but no text will be added to the content of thecard
.
This module supports using a subclass of ReportCard
for added flexibility.
A subclass instance should be passed as the default value of
the card
argument in the card_fun
function.
See below:
CustomReportCard <- R6::R6Class( classname = "CustomReportCard", inherit = teal.reporter::ReportCard ) custom_function <- function(card = CustomReportCard$new()) { card }
Value
NULL
.
Parse a named list to yaml
header for an Rmd
file
Description
Converts a named list into a yaml
header for Rmd
, handling output types and arguments
as defined in the rmarkdown
package. This function simplifies the process of generating yaml
headers.
Usage
as_yaml_auto(
input_list,
as_header = TRUE,
convert_logi = TRUE,
multi_output = FALSE,
silent = FALSE
)
Arguments
input_list |
( |
as_header |
( |
convert_logi |
( |
multi_output |
( |
silent |
( |
Details
This function processes a non-nested (flat) named list into a yaml
header for an Rmd
document.
It supports all standard Rmd
yaml
header fields, including author
, date
, title
, subtitle
,
abstract
, keywords
, subject
, description
, category
, and lang
.
Additionally, it handles output
field types and arguments as defined in the rmarkdown
package.
Value
character
with rmd_yaml_header
class,
result of yaml::as.yaml
, optionally wrapped with internal md_header()
.
Note
Only non-nested lists are automatically parsed.
Nested lists require direct processing with yaml::as.yaml
.
Examples
# nested so using yaml::as.yaml directly
as_yaml_auto(
list(author = "", output = list(pdf_document = list(toc = TRUE)))
)
# auto parsing for a flat list, like shiny input
input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE)
as_yaml_auto(input)
as_yaml_auto(list(author = "", output = "pdf_document", toc = TRUE, keep_tex = "TRUE"))
as_yaml_auto(list(
author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE,
wrong = 2
))
as_yaml_auto(list(author = "", output = "pdf_document", toc = TRUE, keep_tex = 2),
silent = TRUE
)
input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = "True")
as_yaml_auto(input)
as_yaml_auto(input, convert_logi = TRUE, silent = TRUE)
as_yaml_auto(input, silent = TRUE)
as_yaml_auto(input, convert_logi = FALSE, silent = TRUE)
as_yaml_auto(
list(
author = "", output = "pdf_document",
output = "html_document", toc = TRUE, keep_tex = TRUE
),
multi_output = TRUE
)
as_yaml_auto(
list(
author = "", output = "pdf_document",
output = "html_document", toc = "True", keep_tex = TRUE
),
multi_output = TRUE
)
Convert yaml
representation of a boolean strings to logical Values
Description
Converts a single character
string representing a yaml
boolean value into a logical value in R
.
Usage
conv_str_logi(
input,
name = "",
pos_logi = c("TRUE", "true", "True", "yes", "y", "Y", "on"),
neg_logi = c("FALSE", "false", "False", "no", "n", "N", "off"),
silent = TRUE
)
Arguments
input |
( |
name |
( |
pos_logi |
( |
neg_logi |
( |
silent |
( |
Value
input
argument or the appropriate logical
value.
Examples
conv_str_logi <- getFromNamespace("conv_str_logi", "teal.reporter")
conv_str_logi("TRUE")
conv_str_logi("True")
conv_str_logi("off")
conv_str_logi("n")
conv_str_logi("sth")
Download report button module
Description
Provides a button that triggers downloading a report.
For more information, refer to the vignette: vignette("simpleReporter", "teal.reporter")
.
Usage
download_report_button_ui(id)
download_report_button_srv(
id,
reporter,
global_knitr = getOption("teal.reporter.global_knitr"),
rmd_output = c(html = "html_document", pdf = "pdf_document", powerpoint =
"powerpoint_presentation", word = "word_document"),
rmd_yaml_args = list(author = "NEST", title = "Report", date =
as.character(Sys.Date()), output = "html_document", toc = FALSE)
)
Arguments
id |
( |
reporter |
( |
global_knitr |
( |
rmd_output |
( |
rmd_yaml_args |
( |
Details
To access the default values for the global_knitr
parameter,
use getOption('teal.reporter.global_knitr')
. These defaults include:
-
echo = TRUE
-
tidy.opts = list(width.cutoff = 60)
-
tidy = TRUE
ifformatR
package is installed,FALSE
otherwise
Value
NULL
.
Get bootstrap current version
Description
Get bootstrap current version
Usage
get_bs_version()
Note
will work properly mainly inside a tag .renderHook
Extract field from yaml
text
Description
Parses yaml
text, extracting the specified field. Returns list names if it's a list;
otherwise, the field itself.
Usage
get_yaml_field(yaml_text, field_name)
Arguments
yaml_text |
( |
field_name |
( |
Value
If the field is a list, it returns the names of elements in the list; otherwise, it returns the extracted field.
Create markdown
header from yaml
string
Description
This function wraps a yaml
-formatted string in Markdown header delimiters.
Usage
md_header(x)
Arguments
x |
( |
Examples
library(yaml)
yaml_quoted <- getFromNamespace("yaml_quoted", "teal.reporter")
yaml <- list(
author = yaml_quoted("NEST"),
title = yaml_quoted("Report"),
date = yaml_quoted("07/04/2019"),
output = list(pdf_document = list(keep_tex = TRUE))
)
md_header <- getFromNamespace("md_header", "teal.reporter")
md_header(as.yaml(yaml))
Panel group widget
Description
Usage
panel_item(title, ..., collapsed = TRUE, input_id = NULL)
Arguments
title |
( |
... |
content of panel |
collapsed |
( |
input_id |
( |
Value
shiny.tag
.
Print method for the yaml_header
class
Description
Usage
## S3 method for class 'rmd_yaml_header'
print(x, ...)
Arguments
x |
( |
... |
optional text. |
Value
NULL
.
Examples
input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE)
out <- as_yaml_auto(input)
out
print(out)
Server to Load Reporter
Description
Server to load
ReporterCard
(s) to the Reporter
For more details see the vignette: vignette("simpleReporter", "teal.reporter")
.
Usage
report_load_srv(id, reporter)
Arguments
id |
|
reporter |
|
Value
shiny::moduleServer
User Interface to Load Reporter
Description
Button to upload
ReporterCard
(s) to the Reporter
.
For more details see the vignette: vignette("simpleReporter", "teal.reporter")
.
Usage
report_load_ui(id)
Arguments
id |
|
Value
shiny::tagList
Render the report
Description
Render the report and zip the created directory.
Usage
report_render_and_compress(
reporter,
input_list,
global_knitr,
file = tempdir()
)
Arguments
reporter |
( |
input_list |
( |
global_knitr |
( |
file |
( |
Value
file
argument, invisibly.
Get the custom list of UI inputs
Description
Get the custom list of UI inputs
Usage
reporter_download_inputs(rmd_yaml_args, rmd_output, showrcode, session)
Arguments
rmd_yaml_args |
( |
rmd_output |
( |
Report previewer module
Description
Module offers functionalities to visualize, manipulate, and interact with report cards that have been added to a report. It includes a previewer interface to see the cards and options to modify the report before downloading.
Cards are saved by the shiny
bookmarking mechanism.
For more details see the vignette: vignette("previewerReporter", "teal.reporter")
.
Usage
reporter_previewer_ui(id)
reporter_previewer_srv(
id,
reporter,
global_knitr = getOption("teal.reporter.global_knitr"),
rmd_output = c(html = "html_document", pdf = "pdf_document", powerpoint =
"powerpoint_presentation", word = "word_document"),
rmd_yaml_args = list(author = "NEST", title = "Report", date =
as.character(Sys.Date()), output = "html_document", toc = FALSE),
previewer_buttons = c("download", "load", "reset")
)
Arguments
id |
( |
reporter |
( |
global_knitr |
( |
rmd_output |
( |
rmd_yaml_args |
( |
previewer_buttons |
( |
Details
To access the default values for the global_knitr
parameter,
use getOption('teal.reporter.global_knitr')
. These defaults include:
-
echo = TRUE
-
tidy.opts = list(width.cutoff = 60)
-
tidy = TRUE
ifformatR
package is installed,FALSE
otherwise
Value
NULL
.
Reset report button module
Description
Provides a button that triggers resetting the report content.
For more information, refer to the vignette: vignette("simpleReporter", "teal.reporter")
.
Usage
reset_report_button_ui(id, label = NULL)
reset_report_button_srv(id, reporter)
Arguments
id |
( |
label |
( |
reporter |
( |
Value
NULL
.
Get document output arguments from the rmarkdown
package
Description
Retrieves the arguments for a specified document output type from the rmarkdown
package.
Usage
rmd_output_arguments(output_name, default_values = FALSE)
Arguments
output_name |
( |
default_values |
( |
Examples
rmd_output_arguments("pdf_document")
rmd_output_arguments("pdf_document", TRUE)
Get document output types from the rmarkdown
package
Description
Retrieves vector of available document output types from the rmarkdown
package,
such as pdf_document
, html_document
, etc.
Usage
rmd_outputs()
Value
character
vector.
Examples
rmd_outputs()
Simple reporter module
Description
Module provides compact UI and server functions for managing a report in a shiny
app.
This module combines functionalities for adding cards to a report,
downloading the report, and resetting report content.
For more details see the vignette: vignette("simpleReporter", "teal.reporter")
.
Usage
simple_reporter_ui(id)
simple_reporter_srv(
id,
reporter,
card_fun,
global_knitr = getOption("teal.reporter.global_knitr"),
rmd_output = c(html = "html_document", pdf = "pdf_document", powerpoint =
"powerpoint_presentation", word = "word_document"),
rmd_yaml_args = list(author = "NEST", title = "Report", date =
as.character(Sys.Date()), output = "html_document", toc = FALSE)
)
Arguments
id |
( |
reporter |
( |
card_fun |
( |
global_knitr |
( |
rmd_output |
( |
rmd_yaml_args |
( |
Details
To access the default values for the global_knitr
parameter,
use getOption('teal.reporter.global_knitr')
. These defaults include:
-
echo = TRUE
-
tidy.opts = list(width.cutoff = 60)
-
tidy = TRUE
ifformatR
package is installed,FALSE
otherwise
Value
NULL
.
Examples
if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(simple_reporter_ui("simple")),
server = function(input, output, session) {
simple_reporter_srv("simple", Reporter$new(), function(card) card)
}
)
}
Divide text block into smaller blocks
Description
Split a text block into smaller blocks with a specified number of lines.
Usage
split_text_block(x, n)
Arguments
x |
( |
n |
( |
Details
A single character string containing a text block of multiple lines (separated by \n
)
is split into multiple strings with n or less lines each.
Value
List of character strings with up to n
lines in each element.
Convert content into a flextable
Description
Converts supported table formats into a flextable
for enhanced formatting and presentation.
Usage
to_flextable(content)
Arguments
content |
Supported formats: |
Details
Function merges cells with colspan
> 1,
aligns columns to the center and row names to the left,
indents the row names by 10 times indentation.
Value
flextable
.
Mark strings for quotation in yaml
serialization
Description
This function is designed for use with the yaml
package to explicitly,
It adds an attribute to character strings, indicating that they should be serialized with double quotes.
Usage
yaml_quoted(x)
Arguments
x |
( |
Examples
library(yaml)
yaml_quoted <- getFromNamespace("yaml_quoted", "teal.reporter")
yaml <- list(
author = yaml_quoted("NEST"),
title = yaml_quoted("Report"),
date = yaml_quoted("07/04/2019"),
output = list(pdf_document = list(keep_tex = TRUE))
)
as.yaml(yaml)