initEnvimaR: Set up a project environment

Description Usage Arguments Details Value See Also Examples

View source: R/initEnvimaR.R

Description

Set up the project environment with a defined folder structure, an RStudio project, initial script and settings templates and git and dvc repository, if necessary.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
initEnvimaR(
  root_folder = ".",
  folders = NULL,
  folder_names = NULL,
  path_prefix = NULL,
  init_git = TRUE,
  code_subfolders = c("src", "src/functions"),
  init_dvc = TRUE,
  dvc_subfolders = "data",
  dvc_cache = NULL,
  global = FALSE,
  libs = NULL,
  alt_env_id = NULL,
  alt_env_value = NULL,
  alt_env_root_folder = NULL,
  standard_setup = c("envimar", "envimar_no_dvc", "envimar_no_git_dvc")
)

Arguments

root_folder

root directory of the project.

folders

list of subfolders within the project directory that will be created.

folder_names

names of the variable values that point to subfolders. If not provided, the base paths of the folders is used.

path_prefix

a prefix for the variable values that point to the created folders.

init_git

logical: init git repository in the project directory.

code_subfolders

subfolders for scripts and functions within the project directory that will be created. The folders src and src/functions are mandatory.

init_dvc

logical: init dvc repository in the project't git repository.

dvc_subfolders

subfolders for data that should be added to dvc.

dvc_cache

dvc cache directory. If NULL, the default will be used (i.e. local cache) within the dvc repository.

global

logical: export path strings as global variables?

libs

vector with the names of libraries that are required for the initial project.

alt_env_id

alternative system environment attribute used to check for setting an alternative root_folder.

alt_env_value

value of the attribute for which the alternative root directory of the project should be set.

alt_env_root_folder

alternative root directory.

standard_setup

use predefined settings. In this case, only the name of the root folder is required. See names(envimaR::lutInfo()) for available standards.

Details

The function uses createEnvi for setting up the folders. Once the project is creaeted, manage the overall configuration of the project by the src/functions/000_settings.R script. It is sourced at the begining of the template scripts that are created by default. Define additional constans, required libraries etc. in the 000_settings.R at any time. If additonal folders are required later, just add them manually. They will be parsed as part of the 000_settings.R and added to a variable called envrmt that allows easy acces to any of the folders. Use this variable to load/save data to avoid any hard coded links in the scripts except the top-level root folder which is defined once in the main control script located at src/control.R.

Value

envrmt, i.e. a list containing the project settings.

See Also

createEnvi()

Examples

1
2
3
4
5
## Not run: 
root_folder <- tempdir() # Mandatory, variable must be in the R environment.
envrmt <- initEnvimaR(root_folder = root_folder, standard_setup = "envimar")

## End(Not run)

envima/envimaR documentation built on July 18, 2021, 1:40 p.m.