Learn R Programming

drake (version 4.4.0)

Makefile_recipe: Function Makefile_recipe

Description

See what your Makefile recipes will look like in advance.

Usage

Makefile_recipe(recipe_command = drake::default_recipe_command(),
  target = "your_target", cache_path = drake::default_cache_path())

Arguments

recipe_command

The Makefile recipe command. See default_recipe_command().

target

character scalar, name of your target

cache_path

path to the drake cache. In practice, this defaults to the hidden .drake/ folder, but this can be customized. In the Makefile, the drake cache is coded with the Unix variable `DRAKE_CACHE` and then dereferenced with `$(DRAKE_CACHE)`. To simplify things for users who may be unfamiliar with Unix variables, the recipe() function just shows the literal path to the cache.

Details

Makefile recipes to build targets are customizable. Use the Makefile_recipe() function to show and tweak Makefile recipes in advance, and see default_recipe_command() and r_recipe_wildcard() for more clues. The default recipe is Rscript -e 'R_RECIPE', where R_RECIPE is the wildcard for the recipe in R for making the target. In writing the Makefile, R_RECIPE is replaced with something like drake::mk("name_of_target", "path_to_cache"). So when you call make(..., parallelism = "Makefile", recipe_command = "R -e 'R_RECIPE' -q"), # nolint from within R, the Makefile builds each target with the Makefile recipe, R -e 'drake::mk("this_target", "path_to_cache")' -q. But since R -q -e fails on Windows, so the default recipe_command argument is "Rscript -e 'R_RECIPE'" (equivalently just "Rscript -e"), so the default Makefile recipe for each target is Rscript -e 'drake::mk("this_target", "path_to_cache")'.

See Also

default_recipe_command, r_recipe_wildcard, make

Examples

Run this code
# NOT RUN {
Makefile_recipe()
Makefile_recipe(
  target = "this_target",
  recipe_command = "R -e 'R_RECIPE' -q",
  cache_path = "custom_cache"
)
default_recipe_command()
r_recipe_wildcard()
# }
# NOT RUN {
load_basic_example()
# Look at the Makefile generated by the following.
make(my_plan, paralleliem = "Makefile")
# Generates a Makefile with "R -q -e" rather than
# "Rscript -e".
# Be aware the R -q -e fails on Windows.
make(my_plan, parallelism = "Makefile", jobs = 2
  recipe_command = "R -q -e")
# Same thing:
clean()
make(my_plan, parallelism = "Makefile", jobs = 2,
  recipe_command = "R -q -e 'R_RECIPE'")
clean()
make(my_plan, parallelism = "Makefile", jobs = 2,
  recipe_command = "R -e 'R_RECIPE' -q")
# }

Run the code above in your browser using DataLab