This function assists in creating a directory system with different sub-folders to assist in the organisation of the modelling process outputs.
Usage
sdm_directory(
main_dir = NULL,
projections = NULL,
calibration_area = TRUE,
algorithm = NULL,
ensemble = NULL,
threshold = FALSE,
return_vector = TRUE
)
Arguments
- main_dir
character. Directory path containing main folder for saving model inputs and outputs. If NULL function assumes as directory path the current working R session and creates a sub-folder with the name of 'flexsdm_results'. Default NULL
- projections
vector. Vector of folder names for future scenarios/different regions/time periods to save model projections output.
- calibration_area
logical. If TRUE, function creates a folder in 1_Inputs for storing calibration area. Default TRUE
- algorithm
vector. Vector of model names that will be used. Usage algorithm = c(gam, tune_max, tune_net, esm_glm). If "all" is used the function creates folders with all algorithms available in flexsdm . i.e. 'gam', 'gau', 'gbm', 'glm', 'max', 'net', 'raf', and 'svm'. Default NULL
- ensemble
vector. Vector of methods used to ensemble different models. Usage ensemble = c("mean", "meanthr"). Default NULL
- threshold
logical. If TRUE sub-folders "/1_con", "/2_bin" will be created within each algorithm and/or ensemble folder. Used for storing continuous and binarized models separately. Default FALSE
- return_vector
logical. If TRUE function returns a vector with the path to all folders. Default TRUE
Details
The sdm_directory function assists in saving workflow outputs by creating folders (directories) based on user specifications, such as choice of algorithms, ensemble methods, and model projections to new geographic regions or periods. The function first creates two folders within the user-specified project folder, one for model inputs (1_Inputs) and one for model outputs (2_Outputs). Within 1_Inputs, there are three sub-folders for users to store model inputs: 1_Occurrences, 2_Predictors, and 3_Calibration_area. If a user chooses to include projections in their modeling framework, the 2_Projections subfolder is created within the 2_Predictors folder to store the environmental data for the projection scenarios provided to the "projections" argument. Additionally, sdm_directory offers users enhanced flexibility in saving their modeling outputs, giving them offers users the option to save results from any modeling and ensemble technique presented in flexsdm
Examples
if (FALSE) { # \dontrun{
require(dplyr)
# require(sf)
# Implement sdm_directory without specific path and project name
dirs_1 <- sdm_directory(
main_dir = NULL,
projections = NULL,
calibration_area = TRUE,
algorithm = c("gam", "tune_max"),
ensemble = c("mean", "meanthr"),
threshold = FALSE,
return_vector = TRUE
)
dirs_1
dirs_1[1] %>% fs::dir_tree(., recurse = TRUE)
unlink(dirs_1[1], recursive = TRUE) # this directory and sub-folder will be removed
# Implement sdm_directory with specific path and project name
getwd() %>% dirname()
dirs_2 <- sdm_directory(
main_dir = getwd() %>% dirname() %>% file.path(., "my_project_name"),
projections = c(
"cnrm_rpc8.5_2050",
"cnrm_rpc4.5_2050"
),
calibration_area = TRUE,
algorithm = "all",
ensemble = c("mean", "meanthr"),
threshold = TRUE
)
dirs_2[1] %>% fs::dir_tree(., recurse = TRUE)
} # }