knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

pkgtemp

Lifecycle: experimental R-CMD-check

R Markdown Template for Developing R Package :package:

Goal

pkgtemp contains as series of usethis and other commands in an R Markdown that provides a template to kick-start your R package development process. If you want to use your own template from GitHub, this package will facilitate that too.

Prerequisites

You should be somewhat familiar with how to create R Package. Checkout these resources to learn more:

(pkgtemp assumes that R package is develop in RStudio. If you use other IDE you may need to adapt your workflow accordingly.)

Installation

You can install the development version of pkgtemp like so:

# install.packages("remotes")
remotes::install_github("Lightbridge-KS/pkgtemp")

Templates

Workflow

Create R Package by:

usethis::create_package("~/path/to/yourpkg")

Create R Markdown Template for package development by:

pkgtemp::use_pkgbuild_rmd()

This will:

Go to build.Rmd. You will see 2 types of command in there:

Example

# Reset possible options
options(usethis.description = list())
# Create a new package -------------------------------------------------
path <- file.path(tempdir(), "yourpkg")
usethis::create_package(path)

# only needed since this session isn't interactive
usethis::proj_activate(path)
.old_wd <- setwd(path) # Only in this example

# Create Rmd Template for PKG Development
pkgtemp::use_pkgbuild_rmd(open = FALSE)

Custom Template

Everyone can have a different package development workflow. This second approach will allows you to use your default template from a file in GitHub.

Here how it works:

# To edit `~/.Rprofile`
usethis::edit_r_profile()

Copy code below to ~/.Rprofile and provide your pkgbuild_url as URL to your default template.

if (interactive() && requireNamespace("pkgtemp", quietly = TRUE)) {

  pkgtemp::set_github_template_url(
    pkgbuild_url = "https://github.com/OWNER/REPO/blob/REF/path/to/default-template.Rmd"
  )
}
pkgtemp::use_pkgbuild_rmd(remote = TRUE)

Alternatively, If you want to use any other GitHub template just once in a while, provides a url directly.

pkgtemp::use_pkgbuild_rmd(url = "https://github.com/OWNER/REPO/blob/REF/path/to/one-off-template.Rmd")

Last updated: r Sys.Date()



Lightbridge-KS/pkgtemp documentation built on May 10, 2022, 7:33 p.m.