make_template: Linearly combine template elements into templates

Description Usage Arguments Value See Also Examples

View source: R/make_template.R

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

1

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# 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)

heddlr documentation built on March 24, 2020, 9:07 a.m.