make_template {heddlr}R Documentation

Linearly combine template elements into templates

Description

Applying heddle can leave your template pieces stored as either string objects, vectors (standalone or in a dataframe), or nested vectors (if applied using map()). This function takes those elements and combines them into a single exportable template.

Usage

make_template(data, ...)

Arguments

data

The dataframe containing variables to be combined.

...

The variables to be combined into a template object.

Value

Returns the collapsed template as a character string.

See Also

Other manipulation functions: create_yaml_header(), heddle(), provide_parameters(), use_parameters()

Examples


# When passed vectors, make_template flattens each vector into a single
# string and then combines its arguments from left to right
spList <- data.frame(Species = c(unique(iris$Species), "test string"))
make_template(
  heddle(spList, "SPECIES CODE GWAR ", "GWAR" = Species),
  heddle(spList, "SPECIES CODE GWAR ", "GWAR" = Species)
)

# When passed variables in a dataframe, make_template collapses each column
# in turn, then combines the output strings from left to right
spList <- data.frame(Species = c(unique(iris$Species), "test string"))
spList$template <- heddle(spList, "SPECIES CODE GWAR ", "GWAR" = Species)
make_template(spList, template)
make_template(spList, template, template)

# When passed nested columns, heddlr collapses each cell into a string,
# then collapses each column into a string, and then combines the outputs
# from left to right
make_template(tidyr::nest(spList, nested = template), nested)

[Package heddlr version 0.6.0 Index]