Creates a directory with the essential files for a new project. The function can be used on existing project directories as well. Existing files will not be overwritten; rather, the user will be prompted whether to replace the existing file with the template file.
create_project(
path,
path_data = NULL,
template = "default",
git = TRUE,
renv = TRUE,
symlink = git,
renv.settings = NULL,
overwrite = NA,
open = interactive()
)
A path. If it exists, it is used. If it does not exist, it is created.
A path. The directory where the secure data exist. Default is
NULL
. When supplied, a symbolic link to data folder will be created.
A project template. See vignette for details.
Logical indicating whether to create Git repository. Default is TRUE
When NA
, user will be prompted whether to initialise Git repo.
Logical indicating whether to add renv to a project.
Default is TRUE
. When NA
user is asked interactively for preference.
Logical indicating whether to place a symbolic link
to the location in path_data=
. Default is to place the symbolic link
if the project is a git repository.
A list of renv settings passed to renv::scaffold(settings=)
Logical indicating whether to overwrite existing files
if they exist. Options are
TRUE
, FALSE
, and NA
(aka ask interactively). Default is NA
Logical indicating whether to open new project in fresh RStudio session
NULL, places project template in new or existing directory
Users can create a personalized project template. Check out the vignette for step by step instructions.
# specifying project folder location (folder does not yet exist)
project_path <- file.path(tempdir(), "My Project Folder")
# creating folder where secure data would be stored (typically will be a network drive)
secure_data_path <- file.path(tempdir(), "secure_data")
dir.create(secure_data_path)
# creating new project folder
create_project(project_path, path_data = secure_data_path)
#> ✔ Using "Default Project Template" template
#> ✔ Writing folder /tmp/RtmphZc7LW/My Project Folder
#> ✔ Writing files "README.md", ".gitignore", "My Project Folder.Rproj", and ".Rprofile"
#> ✔ Creating symbolic link to data folder /tmp/RtmphZc7LW/secure_data
#> ✔ Initialising Git repo
#> ✔ Initialising renv project
#> - Lockfile written to "/tmp/RtmphZc7LW/My Project Folder/renv.lock".
#> - renv infrastructure has been generated for project "/tmp/RtmphZc7LW/My Project Folder".