Title: | Starter Kit for New Projects |
---|---|
Description: | Get started with new projects by dropping a skeleton of a new project into a new or existing directory, initialise git repositories, and create reproducible environments with the 'renv' package. The package allows for dynamically named files, folders, file content, as well as the functionality to drop individual template files into existing projects. |
Authors: | Daniel D. Sjoberg [aut, cre] , Emily Vertosick [ctb] |
Maintainer: | Daniel D. Sjoberg <[email protected]> |
License: | AGPL (>= 3) |
Version: | 0.1.15.9000 |
Built: | 2024-11-14 05:30:45 UTC |
Source: | https://github.com/ddsjoberg/starter |
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() )
create_project( path, path_data = NULL, template = "default", git = TRUE, renv = TRUE, symlink = git, renv.settings = NULL, overwrite = NA, open = interactive() )
path |
A path. If it exists, it is used. If it does not exist, it is created. |
path_data |
A path. The directory where the secure data exist. Default is
|
template |
A project template. See vignette for details. |
git |
Logical indicating whether to create Git repository. Default is |
renv |
Logical indicating whether to add renv to a project.
Default is |
symlink |
Logical indicating whether to place a symbolic link
to the location in |
renv.settings |
A list of renv settings passed to |
overwrite |
Logical indicating whether to overwrite existing files
if they exist. Options are
|
open |
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.
Daniel D. Sjoberg
# 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)
# 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)
The starter_symlink()
function is an OS agnostic function that creates symbolic
links between two folders. The function is, at its core, a wrapper for the
R.utils::createLink()
function with opinionated
defaults. The function must be called in an environment where the working
directory is known (e.g. using *.Rproj
, setwd()
, etc.).
create_symlink(to, name = "secure_data", ...)
create_symlink(to, name = "secure_data", ...)
to |
target file or directory to which the shortcut should point to. |
name |
symbolic link folder name. Default folder name is |
... |
arguments passed on to |
A symbolic link is a special kind of file that points to another file/folder. A symbolic link does not contain the data in the target file. It simply points to another entry somewhere in the file system. This allows symbolic links to link to directories or files on remote network locations. Depending on your operating system, a link may not establish if the originating path is a network drive.
NULL, Places the path or pathname to the link.
Daniel D. Sjoberg
# Using `starter_symlink()` to establish a symbolic link to a # mapped networked data folder. # The default name of the symlink folder is 'secure_data' create_symlink("O:/Outcomes/Project Folder/Data")
# Using `starter_symlink()` to establish a symbolic link to a # mapped networked data folder. # The default name of the symlink folder is 'secure_data' create_symlink("O:/Outcomes/Project Folder/Data")
The project_templates
object defines the contents of the project
templates used in create_project()
and use_file()
.
project_templates
project_templates
A named list containing the project templates.
if (FALSE) { create_project( path = file.path(tempdir(), "Sjoberg New Project"), template = project_templates[["analysis"]] ) }
if (FALSE) { create_project( path = file.path(tempdir(), "Sjoberg New Project"), template = project_templates[["analysis"]] ) }
Rather than using create_project()
to start a new project folder, you
may use use_project_file()
to write a single file from any project template.
The functions use_project_gitignore()
and use_project_readme()
are shortcuts for
use_project_file("gitignore")
and use_project_file("readme")
.
use_project_file( name = NULL, filename = NULL, template = NULL, open = interactive() ) use_project_gitignore(filename = NULL, template = NULL) use_project_readme(filename = NULL, template = NULL)
use_project_file( name = NULL, filename = NULL, template = NULL, open = interactive() ) use_project_gitignore(filename = NULL, template = NULL) use_project_readme(filename = NULL, template = NULL)
name |
Name of file to write. Not sure of the files available to you? Run the function without specifying a name, and all files available within the template will print. |
filename |
Optional argument to specify the name of the file to be written. Paths/filename is relative to project base |
template |
A project template. See vignette for details. |
open |
If |
NULL, places single template file in current working directory
# only run fn interactively, will place files in current working dir if (interactive()) { # create gitignore file use_project_file("gitignore") use_project_gitignore() # create README.md file use_project_file("readme") use_project_readme() }
# only run fn interactively, will place files in current working dir if (interactive()) { # create gitignore file use_project_file("gitignore") use_project_gitignore() # create README.md file use_project_file("readme") use_project_readme() }