projects (version 1.1.1)

setup_projects: Set up the projects folder

Description

Creates or restores the projects folder at the user-specified path.

Usage

setup_projects(path, overwrite = FALSE, make_directories = FALSE,
  .Renviron_path = fs::path_home_r(".Renviron"))

Arguments

path

The full file path where the user would like a directory called "projects" to be created, wherein all projects and their data will dwell.

overwrite

Logical indicating whether or not to abandon any previously stored projects folders stored in the system.

make_directories

Logical indicating whether or not the function should write any directories specified in the path argument that don't already exist.'

.Renviron_path

The full file path of the .Renviron file where the user would like to store the projects_folder() path. Default is the home .Renviron file. If the file doesn't exist it will be created.

Value

The project folder's path, invisibly. It will be "" if it doesn't exist.

Default contents

The projects folder automatically contains the subdirectories .metadata and .template, which are hidden by default on some operating systems.

The .metadata folder and its contents should never be manually moved or modified.

The .templates will contain several templates that new_project() reads when creating a new project. Advanced users may edit these templates or add their own. See new_project() for details.

Behavior when projects folder already exists

If overwrite = TRUE, the function will run no matter what. Use with caution.

If the user has a pre-existing projects folder and runs this command with the pre-existing projects folder's path, nothing will be deleted.

Therefore, if the user "broke" the projects folder (e.g., by deleting metadata; by changing the "PROJECTS_FOLDER_PATH" line in the .Renviron file), the user can "fix" the projects folder to some degree by running this function with the folder's actual file path (e.g., restore all default templates; restore missing metadata files).

Details

The projects package remembers where the projects folder is located by storing its file path in a .Renviron file (the home .Renviron file by default). The entry is named PROJECTS_FOLDER_PATH.

Note that changing the .Renviron_path argument may create an .Renviron file that R will not notice or use. See Startup for more details.

See Also

new_project() for information on templates

Startup for more information on how .Renviron files work.

Examples

Run this code
# NOT RUN {
# This sequence is used in all other examples in this package.

# Back up old projects_folder()
old_path <- Sys.getenv("PROJECTS_FOLDER_PATH")

# This sets up an example projects_folder() in a temporary directory.
# It will not edit any of the user's .Renviron files.
setup_projects(path = tempdir(), .Renviron_path = fs::path_temp(".Renviron"))

# Cleanup
Sys.setenv(PROJECTS_FOLDER_PATH = old_path)
fs::file_delete(c(fs::path_temp("projects"), fs::path_temp(".Renviron")))
# }

Run the code above in your browser using DataLab