RcodeBlock: 'RcodeBlock'

RcodeBlockR Documentation

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) or character(0)) a string assigned to this RcodeBlock

...

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) any rmarkdown 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 fields text and params. Use the get_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()


teal.reporter documentation built on April 3, 2025, 7:39 p.m.