org::initialize_project
takes in 2+ arguments.
It then saves folder locations in the return value (a new environment) and
in org::project
, which you will use in all of your subsequent code. An additional
folder will be created on the user's file system (org::project$results_today) which
corresponds to results/YYYY-MM-DD
. The sourced folders are saved into org::project$env.
Usage
initialize_project(
env = new.env(),
home = NULL,
results = NULL,
folders_to_be_sourced = "R",
source_folders_absolute = FALSE,
encode_from = "UTF-8",
encode_to = "latin1",
...
)
Arguments
- env
The environment that the code will be sourced into (use
.GlobalEnv
to source code into the global environment)- home
The folder containing 'Run.R' and 'R/'
- results
A folder inside
results
with today's date will be created and it will be accessible viaorg::project$results_today
(this is where you will store all of your results)- folders_to_be_sourced
The names of folders that live inside
home
and all .r and .R files inside it will be sourced into the global environment.- source_folders_absolute
If
TRUE
thenfolders_to_be_sourced
is an absolute folder reference. IfFALSE
thenfolders_to_be_sourced
is relative and insidehome
.- encode_from
Folders current encoding (only used on Windows)
- encode_to
Folders final encoding (only used on Windows)
- ...
Other folders that you would like to reference
Value
Returns an environment that contains:
Folder locations
An environment called
env
into which the code has been sourced into. There is also a side effect whereorg::project
mirrors these values.
Examples
# \donttest{
org::initialize_project(
home = paste0(tempdir(), "/git/analyses/2019/analysis3/"),
results = paste0(tempdir(), "/dropbox/analyses_results/2019/analysis3/"),
raw = paste0(tempdir(), "/data/analyses/2019/analysis3/")
)
#> You are NOT sourcing into .GlobalEnv. All functions will be sourced into an environment that is returned from this function.
#> Warning: Folder /tmp/RtmpUUxzgB/git/analyses/2019/analysis3/R does not exist. Creating it now.
#> Sourcing all code inside /tmp/RtmpUUxzgB/git/analyses/2019/analysis3/R into
#> <environment: 0x55ee2c202050>
org::project$results_today
#> [1] "/tmp/RtmpUUxzgB/dropbox/analyses_results/2019/analysis3/2024-06-12/"
org::project$raw
#> [1] "/tmp/RtmpUUxzgB/data/analyses/2019/analysis3/"
# }