Skip to contents

CRAN Version Total Downloads Last Month Downloads Last Week Downloads

Check 🛠 Docs 📚 Code Coverage 📔

GitHub forksGitHub repo stars

GitHub commit activityGitHub contributorsGitHub last commitGitHub pull requestsGitHub repo sizeGitHub language countProject Status: Active – The project has reached a stable, usable state and is being actively developed. Current Version Open Issues

Overview

teal.code is an R library providing tools to store code and an execution environment associated with it. The features include:

  • an object qenv for storing code and an execution environment which integrates well with shiny reactives for use in shiny applications whose outputs require reproducibility (i.e. the code used to generate them)
  • ability to chain and join qenv objects together to provide fine-grained control over executed code
  • automatic error and warning handling for executed code

teal.code also ships a shiny module that helps inspect the stored code as well as messages, warnings and error messages resulting from evaluation via shiny web application.

Installation

From July 2023 insightsengineering packages are available on r-universe.

# stable versions
install.packages('teal.code', repos = c('https://insightsengineering.r-universe.dev', 'https://cloud.r-project.org'))

# install.packages("pak")
pak::pak("insightsengineering/teal.code@*release")

Alternatively, you might also use the development version.

# beta versions
install.packages('teal.code', repos = c('https://pharmaverse.r-universe.dev', 'https://cloud.r-project.org'))

# install.packages("pak")
pak::pak("insightsengineering/teal.code")

Usage

To understand how to use this package, please refer to the Getting Started article, which provides multiple examples of code implementation.

Below is the showcase of the example usage

library(teal.code)
my_qenv <- new_qenv(env = list2env(list(x = 5)), code = "x <- 5")
my_qenv
#> Parent: <environment: package:teal.code>
#> Bindings:
#> • x: <dbl> [L]
qenv_2 <- eval_code(my_qenv, "y <- x * 2") |> eval_code("z <- y * 2")
qenv_2
#> <environment: 0x00000135b544cfe8> [L]
#> Parent: <environment: package:teal.code>
#> Bindings:
#> • x: <dbl> [L]
#> • y: <dbl> [L]
#> • z: <dbl> [L]
qenv_2[["y"]]
#> [1] 10
cat(paste(get_code(qenv_2), collapse = "\n"))
#> x <- 5
#> y <- x * 2
#> z <- y * 2

Getting help

If you encounter a bug or you have a feature request - please file an issue. For questions, discussions and staying up to date, please use the “teal” channel in the pharmaverse slack workspace.

Stargazers and Forkers

Stargazers over time

Stargazers over time

Stargazers

Stargazers repo roster for @insightsengineering/teal.code

Forkers

Forkers repo roster for @insightsengineering/teal.code