Closed biocyberman closed 6 years ago
I'm not sure. I always use reload.project()
as first statements in the scripts in src/
-- this doesn't make them self-contained, but you need the data files anyway. Of course, this only works with munging: FALSE
and everything in cache.
I think it would be better if create.file.template
is implemented. But thanks for mentioning of reload.project()
at the head of every src
file.
My main concern is that the information becomes out of date if you change your configuration. However, I'd review a pull request that creates a header with a comment and the statements calls
library(ProjectTemplate)
reload.project()
.
I would like to put a request on a feature that allows creating various file templates:
Currently the project configuration file
config/global.dcf
file is good to load the project as a whole and any scripts therein will not have to handle library import and data preparation. But if we just one to run one script in withR --vanilla
for example, this would not work because libraries and data are missing. My suggestion is to implement a function likecreate.file.template(name = "file_name", dir = "munge", type = c("R", "Rmd")[1], library = c("dplyr", "lubridate", "ggplot2"), data = "my_dataset1")
. The function then create a file with appropriate content template based on input parameters. For example, with the aforementioned command, it would create an R file undermunge
directory with the beginning of the file like so:This way the file is both consistent with project structure and self-contained.
Would this be something worth doing?