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
orderly_develop_start()
this can beNULL
if you have already set the working directory to be the source directory.- root
The path to an orderly root directory, or
NULL
(the default) to search for one from the current working directory iflocate
isTRUE
.- locate
Logical, indicating if the configuration should be searched for. If
TRUE
andconfig
is not given, then orderly looks in the working directory and up through its parents until it finds anorderly_config.yml
file.- show
Logical, indicating if we should print the proposed changes to screen
- edit
Logical, indicating if we should actually edit the
orderly.yml
file.- prompt
Logical, indicating if we should prompt before editing the orderly.yml file. Only has an effect if
edit
isTRUE
.- packages
Character vector of package names to add. These must not already exist in the orderly.yml
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.
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.
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)
#> Changes to 'src/example/orderly.yml'
#> 8 | filenames: mygraph.png
#> 9 |
#> 10 |
#> 11 | resources:
#> 12 | - mtcars.csv
# Modify the orderly.yml file within src/example:
orderly::orderly_use_resource("mtcars.csv", "example", path, prompt = FALSE)
#> Changes to 'src/example/orderly.yml'
#> 8 | filenames: mygraph.png
#> 9 |
#> 10 |
#> 11 | resources:
#> 12 | - mtcars.csv
#> Writing to 'src/example/orderly.yml'
# The result is a file that now has a 'resources' section
# containing our new file
writeLines(readLines(file.path(path, "src", "example", "orderly.yml")))
#> data:
#> dat:
#> query: SELECT name, number FROM thing
#> script: script.R
#> artefacts:
#> staticgraph:
#> description: A graph of things
#> filenames: mygraph.png
#>
#>
#> resources:
#> - mtcars.csv
# (of course, we'd still need to modify the script to use it).