Learn R Programming

mighty.component

mighty.component provides reusable code templates, called components, for the {mighty} framework, used to generate ADaM programs. Components are Mustache templates documented with roxygen-like tags. Retrieve them from local directories, GitHub or URLs, then render, validate, evaluate and test them.

Installation

# Install the released version from CRAN:
install.packages("mighty.component")
# Install the development version from GitHub:
pak::pak("NovoNordisk-OpenSource/mighty.component")

Usage

Get a component by name from a repo. Repos can be local directories, github::owner/repo/subdir@ref or url::https://.... With several repos, they are searched in order and the first match is used.

library(mighty.component)

repo <- system.file("examples", package = "mighty.component")
ady <- get_component("ady", repos = repo)
ady
#> <mighty_component/R6>
#> ady: Analysis relative day
#> Type: column
#> Parameters:
#> • domain: `character` Name of new domain being created
#> • variable: `character` Name of new variable to create
#> • date: `character` Name of date variable to use
#> Depends:
#> • {{{domain}}}.{{{date}}}
#> • {{{domain}}}.TRTSDT
#> Outputs:
#> • {{{variable}}}

Render it with study-specific parameters:

ady$render(domain = "ADAE", variable = "ASTDY", date = "ASTDT")
#> <mighty_component_rendered/mighty_component/R6>
#> ady: Analysis relative day
#> Type: column
#> Depends:
#> • ADAE.ASTDT
#> • ADAE.TRTSDT
#> Outputs:
#> • ASTDY
#> Code:
#> ADAE <- ADAE |>
#>   dplyr::mutate(
#>     ASTDY = admiral::compute_duration(
#>       start_date = TRTSDT,
#>       end_date = ASTDT,
#>       in_unit = 'days',
#>       out_unit = 'days',
#>       add_one = TRUE
#>     )
#>   )

Rendered components can be evaluated with $eval(), written to a script with $stream(), and unit tested with get_test_component(). See vignette("mighty-component") for details.

Copy Link

Version

Install

install.packages('mighty.component')

Version

0.2.0

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Aksel Thomsen

Last Published

November 12th, 2026

Functions in mighty.component (0.2.0)

mighty_component

Mighty component class
get_test_component

Create a test component
mighty.component-options

Options for mighty.component
list_components

List components in repos
mighty.component-options-params

Internal parameters for reuse in functions
mighty_component_test

Test mighty component class
mighty_component_rendered

Rendered mighty component class
mighty_repo

Component repos
get_component

Retrieve a component
mighty_repo_local

Local component repo
find_component

Find a component
mighty_repo_github

GitHub component repo
mighty_repo_url

URL component repo
mighty_repos

Collection of component repos