orderly_use_resource {orderly} | R Documentation |
Add a resource to orderly.yml
Description
Add one or more resources to an orderly.yml
file.
Usage
orderly_use_resource(
resources,
name = NULL,
root = NULL,
locate = TRUE,
show = TRUE,
edit = TRUE,
prompt = TRUE
)
orderly_use_source(
sources,
name = NULL,
root = NULL,
locate = TRUE,
show = TRUE,
edit = TRUE,
prompt = TRUE
)
orderly_use_package(
packages,
name = NULL,
root = NULL,
locate = TRUE,
show = TRUE,
edit = TRUE,
prompt = TRUE
)
orderly_use_gitignore(
root = NULL,
locate = TRUE,
show = TRUE,
edit = TRUE,
prompt = TRUE
)
Arguments
resources , sources |
Character vector of resources or sources to add. These must be filenames relative to the report directory, must exist, and must not already be present in the orderly.yml |
name |
Name of the report to modify. Like
|
root |
The path to an orderly root directory, or |
locate |
Logical, indicating if the configuration should be
searched for. If |
show |
Logical, indicating if we should print the proposed changes to screen |
edit |
Logical, indicating if we should actually edit the
|
prompt |
Logical, indicating if we should prompt before
editing the orderly.yml file. Only has an effect if |
packages |
Character vector of package names to add. These must not already exist in the orderly.yml |
Details
The orderly_use_gitignore
configures a basic
.gitignore
file at the root of your orderly project that
will prevent files from being added to git. This is only really
useful if you are using (or will use) git, but it is harmless at
worst.
Value
Invisibly, this function returns information about the file it would edit. This information is primarily for debugging purposes and the format is subject to change.
Examples
path <- orderly::orderly_example("minimal")
# Suppose we wanted to use the mtcars data within our report.
# First, the file must exist:
write.csv(mtcars, file.path(path, "src", "example", "mtcars.csv"),
row.names = FALSE)
# Preview expected changes
orderly::orderly_use_resource("mtcars.csv", "example", path, edit = FALSE)
# Modify the orderly.yml file within src/example:
orderly::orderly_use_resource("mtcars.csv", "example", path, prompt = FALSE)
# The result is a file that now has a 'resources' section
# containing our new file
writeLines(readLines(file.path(path, "src", "example", "orderly.yml")))
# (of course, we'd still need to modify the script to use it).