Learn R Programming

mighty.component (version 0.2.0)

get_component: Retrieve a component

Description

  • get_component(): Find a component. Raises an error if it is not found.

  • get_rendered_component(): Find a component and render it with params.

Usage

get_component(component, repos = NULL)

get_rendered_component(component, params = list(), repos = NULL)

Value

  • get_component(): A mighty_component object.

  • get_rendered_component(): A mighty_component_rendered object.

Arguments

component

character(1) Component name. If repos is NULL, path to a component file.

repos

Where to look. One of:

  • NULL (default): component is a file path.

  • character vector of repo specs, in priority order. See mighty_repo().

  • A mighty_repo_class object.

  • A list of repo specs or mighty_repo_class objects, in priority order.

  • A mighty_repos() collection.

Character vectors and lists are converted once with mighty_repos().

params

named list of parameters passed to $render(). See the component's @param tags (component$params).

Details

Components are .mustache or .R files. Both use the tags described in mighty_component.

  • .mustache files are Mustache templates.

  • .R files are plain R components. They cannot have @param tags or Mustache placeholders.

See Also

find_component(), mighty_component, mighty_component_rendered

Examples

Run this code
path <- system.file("examples", "ady.mustache", package = "mighty.component")
get_component(path)

get_rendered_component(
  component = path,
  params = list(domain = "ADAE", variable = "ASTDY", date = "ASTDT")
)

# Find by name in a repo
repo <- system.file("examples", package = "mighty.component")
get_component("ady", repos = repo)

Run the code above in your browser using DataLab