| makefile | R Documentation |
Create a Makefile for a data analysis workflow. The Makefile can include rules extracted from existing R files.
makefile(
path_files = NULL,
dir_make = NULL,
name_make = "Makefile",
overwrite = FALSE,
quiet = FALSE
)
path_files |
A path from |
dir_make |
The directory where
|
name_make |
The name of the Makefile.
The default is |
overwrite |
Whether to overwrite
an existing Makefile. Default is |
quiet |
Whether to suppress
progress messages. Default is |
To create a Makefile in the files
directory, set files to ".".
To obtain the contents of the Makefile
without creating a file on disk,
creating the file on disk, set
name_make to NULL.
Supplying a value for files is
optional for makefile(),
but compulsory for shell_script().
The output from makefile()
includes some general-purpose Makefile
commands, while the output from
shell_script() is generated entirely
from files.
makefile() is called for its
side effect, which is to create a
file. However, makefile() also
returns a string with the contents of the
Makefile.
Project Management with Make Makefiles in data analysis workflows
GNU make Definitive guide
Command-Line Programs Introduction to Rscript
Creating a Makefile
More on makefile()
extract_make() Turn a cmd_assign() call into a Makefile rule
shell_script() Shell script equivalent of makefile()
cmd_assign() Process command line arguments
Modular Workflows for Data Analysis Safe, flexible data analysis workflows
littler Alternative to Rscript
library(fs)
library(withr)
with_tempdir({
## create 'src' directory
dir_create("src")
## put R scripts containing calls to
## 'cmd_assign' in the 'src' directory
writeLines(c("cmd_assign(x = 1, .out = 'out/results.rds')",
"results <- x + 1",
"saveRDS(results, file = .out)"),
con = "src/results.R")
writeLines(c("cmd_assign(x = 1, .out = 'out/more_results.rds')",
"more_results <- x + 2",
"saveRDS(more_results, file = .out)"),
con = "src/more_results.R")
## call 'makefile()'
makefile(path_files = "src",
dir_make = ".")
## Makefile has been created
dir_tree()
## print contents of Makefile
cat(readLines("Makefile"), sep = "\n")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.