Package 'starter'

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

Help Index


Start a new project

Description

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.

Usage

create_project(
  path,
  path_data = NULL,
  template = "default",
  git = TRUE,
  renv = TRUE,
  symlink = git,
  renv.settings = NULL,
  overwrite = NA,
  open = interactive()
)

Arguments

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 NULL. When supplied, a symbolic link to data folder will be created.

template

A project template. See vignette for details.

git

Logical indicating whether to create Git repository. Default is TRUE When NA, user will be prompted whether to initialise Git repo.

renv

Logical indicating whether to add renv to a project. Default is TRUE. When NA user is asked interactively for preference.

symlink

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.

renv.settings

A list of renv settings passed to renv::scaffold(settings=)

overwrite

Logical indicating whether to overwrite existing files if they exist. Options are TRUE, FALSE, and NA (aka ask interactively). Default is NA

open

Logical indicating whether to open new project in fresh RStudio session

Value

NULL, places project template in new or existing directory

Personalized Template

Users can create a personalized project template. Check out the vignette for step by step instructions.

Author(s)

Daniel D. Sjoberg

See Also

use_project_file()

Vignette for create_project()

Examples

# 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)

Project templates

Description

The project_templates object defines the contents of the project templates used in create_project() and use_file().

Usage

project_templates

Format

A named list containing the project templates.

Examples

if (FALSE) {
create_project(
  path = file.path(tempdir(), "Sjoberg New Project"),
  template = project_templates[["analysis"]]
)
}

Write a template file

Description

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").

Usage

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)

Arguments

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 TRUE, opens the new file.

Value

NULL, places single template file in current working directory

See Also

create_project()

Vignette for create_project()

Examples

# 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()
}