Skip to contents

[Stable] Return the R-code used to create a teal::teal] module analysis. This function will return all analysis code as a character string. In case of a good setup it will not only return the code used create the module analysis, but also the code used by the app author to create the app. The main feature of this function is encapsulating the R code to merge datasets by teal.transform::merge_datasets() and all the R code stored inside code teal.code::chunks.

Usage

get_rcode(
  datasets = NULL,
  datanames = if (is.null(datasets)) datasets else datasets$datanames(),
  chunks = teal.code::get_chunks_object(),
  selected_chunk_ids = character(0),
  session = NULL,
  title = NULL,
  description = NULL
)

Arguments

datasets

(list) list of FilteredData available inside the server function of any teal module.

datanames

(character)
names of datasets which code should be returned for. Due to fact that teal filter panel depending on "ADSL", code for ADSL is always returned even if not specified.

chunks

(chunks)
object of class chunks that stores code chunks. These code chunks are used in teal to enable reproducibility. Normally these chunks are stored within the shiny::shiny-package session. The default value can normally be used.

selected_chunk_ids

(character vector)
vector of code chunks to be shown in the code. If chunk id's are available this can be used to limit the chunks that appear in the "Show R-Code" modal. Please only use this feature if all chunks were set with designated IDs.

session

(environment) deprecated.

title

A character title of the module

description

A character description of the module with additional information not reflected in the title

Value

Return the R Code needed to reproduce a teal module. The get_rcode_header() part allows to install the module. Additionally if the user filtered data by teal inherited functions, the code to filter the data is included. If the teal module is using teal.transform::data_extract_srv() the extraction and merging code will be returned, too. If code chunks were used, these will also be used to derive module R Code.

Note

The teal.load_nest_code option is being used to customize the code that sets correct library paths with all packages available. If empty (the default), a placeholder string is being used.

Examples

if (FALSE) {
show_rcode_modal(
  title = "R Code for a Regression Plot",
  rcode = get_rcode(
    datasets = datasets,
    title = title,
    description = description
  )
)
}