create_proj: Create new data analysis project as R package

View source: R/create_proj.R

create_projR Documentation

Create new data analysis project as R package

Description

Create all the scaffolding for a new project in a new directory. The scaffolding includes a README file, different folders to hold raw data, analyses, etc, a _targets.R pipeline template, renv dependency management, and a CITATION.cff file. Optionally, initialize a git repository and/or set up a private or public GitHub repo with GitHub Actions CI.

Usage

create_proj(
  name,
  data_raw = TRUE,
  makefile = FALSE,
  testthat = FALSE,
  use_pipe = FALSE,
  add_license = NULL,
  license_holder = "Your name",
  orcid = NULL,
  use_git = TRUE,
  create_github_repo = FALSE,
  private_repo = TRUE,
  ci = "none",
  use_renv = TRUE,
  use_targets = TRUE,
  use_docker = FALSE,
  open_proj = FALSE,
  verbose = FALSE
)

Arguments

name

Character. Name of the new project. Could be a path, e.g. "~/myRcode/newproj". A new folder will be created with that name. The directory name can contain underscores or hyphens (e.g. "my_project") — these will be automatically converted to dots for the internal R package name (e.g. my.project in DESCRIPTION).

data_raw

Logical. If TRUE (default), adds a data-raw/ folder for all the raw data files, including a clean_data.R script file for generating clean datasets, a DATA_SOURCES.md for documenting data provenance (source, license, download date, DOI), and a README.

makefile

Logical. If TRUE, adds a template makefile.R file to the project.

testthat

Logical. If TRUE, adds testthat infrastructure.

use_pipe

Logical. If TRUE, adds magrittr's pipe operator to the package. Default is FALSE since R >= 4.1.0 provides the native pipe operator |> which is recommended instead.

add_license

Character. Type of license to add. Options are "MIT", "GPL", "AGPL", "LGPL", "Apache", "CCBY", or "CC0". Default is NULL (no license added).

license_holder

Character. Name of the license holder / project author. Also used in CITATION.cff. Default is "Your name".

orcid

Character. ORCID iD of the project author (e.g. "0000-0001-7986-0308"). Used in CITATION.cff. Default is NULL.

use_git

Logical. If TRUE (default), initializes a local git repository.

create_github_repo

Logical. If TRUE, creates a GitHub repository. Note this requires some working infrastructure like git and a GITHUB_PAT. See https://usethis.r-lib.org/articles/articles/usethis-setup.html.

private_repo

Logical. If TRUE (default), the GitHub repo will be private.

ci

Character. Type of continuous integration for your GitHub repository. Options are "none" (default) or "gh-actions" (uses GitHub Actions with R CMD check). Only used when create_github_repo = TRUE.

use_renv

Logical. If TRUE (default), initializes renv for dependency management. Creates a lockfile and .Rprofile bootstrap.

use_targets

Logical. If TRUE (default), adds a _targets.R template file for pipeline-based workflow management.

use_docker

Logical. If TRUE, adds a template Dockerfile for building a reproducible computational environment.

open_proj

Logical. If TRUE, opens the newly created RStudio project in a new session. Default is FALSE — open the .Rproj file manually after creation.

verbose

Logical. If TRUE, prints verbose output in the console while creating the new project. Default is FALSE.

Details

SCIproj creates a research compendium that combines structure (where files live) with workflow (how analyses are reproduced). By default, it sets up:

  • renv for dependency management (reproducible package versions)

  • targets for pipeline-based workflow (automatic dependency tracking and caching)

  • CITATION.cff for machine-readable citation metadata (FAIR)

  • DATA_SOURCES.md for data provenance documentation

Since R >= 4.1.0, the native pipe operator |> is available and recommended over the magrittr pipe %>%. The use_pipe parameter is therefore set to FALSE by default.

Value

Invisibly returns the path to the new project directory.

Examples

## Not run: 
library("SCIproj")

# Minimal project (includes renv + targets by default)
create_proj("myproject")

# Names with underscores/hyphens are fine — the R package name is
# auto-cleaned (e.g. "baltic_cod" -> "baltic.cod" in DESCRIPTION)
create_proj("baltic_cod_analysis")

# Full-featured project
create_proj("my_research_project",
  add_license = "MIT",
  license_holder = "Jane Doe",
  orcid = "0000-0001-2345-6789",
  create_github_repo = TRUE,
  ci = "gh-actions"
)

# Minimal without workflow tools
create_proj("myproject", use_renv = FALSE, use_targets = FALSE)

## End(Not run)

SCIproj documentation built on March 18, 2026, 5:07 p.m.