View source: R/create_directory.R
create_directory | R Documentation |
Function ment to create subdirectories to save the results of the current step.
create_directory(called_from, dir_results = base::getwd(), results_name = VCFtoGWAS::name_by_time())
called_from |
The function (and step in the process) from which the function was called. Is added to the name of the subdirectory that is created by the function. |
dir_results |
The directory in which a subfolder will be created and results will be saved. Make sure it exists!!! |
results_name |
The results_name parameter dictates the folder (within dir_results folder) that will be created to save the results.
|
Tomer Antman
## The function is currently defined as function (called_from, dir_results = getwd(), results_name = name_by_time()) { results_name <- paste0(results_name, "_", deparse(substitute(called_from)), "-results") results_directory <- paste0(dir_results, "/", results_name) dir.create(results_directory) if (grepl("No such file or directory", names(last.warning))) { message(results_name, " folder couldn't be created because\n", dir_results, " directory doesn't exist.\nTrying to create ", results_name, " folder in\n", getwd()) results_directory2 <- paste0(getwd(), "/", results_name) dir.create(results_directory2) if (grepl("No such file or directory", names(last.warning))) { stop("Couldn't create a directory to save the results") } else { results_directory <- results_directory2 message("Results will be saved into: \n", results_directory) } } else if (grepl("already exists", names(last.warning))) { message("The results directory already exists, the results will be saved in:\n", results_directory) } else { message("Results directory created:\n", results_directory) } return(results_directory) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.