As TJ Mahr pointed out to me recently, use_template()
could be handy for solving use_drake() · Issue #773 · ropensci/drake · GitHub. However, use_template()
appears to focus on individual template files, whereas use_drake() · Issue #773 · ropensci/drake · GitHub needs a slightly more complicated directory structure.
_drake.R
make.R
R/
├── packages.R
├── functions.R
└── plan.R
The R/
directory appears challenging.
dir.create("lib")
.libPaths("lib")
remotes::install_github(
"ropensci/drake",
ref = "372ceeea974d22aef24395f04155ca512c078792",
lib = "lib",
quiet = TRUE
)
usethis::create_project(".")
#> ✔ Setting active project to '/tmp/RtmpAugJFV/reprex24d36b004e55'
#> ✔ Creating 'R/'
#> ✔ Writing a sentinel file '.here'
#> ● Build robust paths within your project via `here::here()`
#> ● Learn more at https://here.r-lib.org
system.file(
file.path("templates", "usedrake", "R"),
package = "drake",
mustWork = TRUE
)
#> [1] "/tmp/RtmpAugJFV/reprex24d36b004e55/lib/drake/templates/usedrake/R"
usethis::use_template(
file.path("usedrake", "R"),
save_as = "R",
package = "drake"
)
#> Error in if (is.null(template) || template == "") {: missing value where TRUE/FALSE needed
Created on 2019-03-13 by the reprex package (v0.2.1)
Can the usethis
API create an R/
folder at the project root while invoking the same checks and safeguards as use_template()
? If not, what should I keep in mind as I implement a safe manual workaround?