Skip to content

Latest commit

 

History

History
59 lines (55 loc) · 1.64 KB

SubmitToCRAN.md

File metadata and controls

59 lines (55 loc) · 1.64 KB

Submit an R package to CRAN

The overall flow can be thought of as follows:

  1. Build/test the package localy
  2. Run alternitive tests
  3. Submit it CRAN

The detailes steps are found below:

  1. Clone the repo
  2. Open RStudio and run the below.
  3. Load packages
pkgs <- installed.packages()
pkg_name <- 'xxx'
pkg_path <- 'd:/repos/yyy/xxx'
pkg_pkg <- paste0('package:', pkg_name)
if (!('devtools' %in% pkgs)) { install.packages('devtools') }
if (!('roxygen2' %in% pkgs)) { install.packages('roxygen2') }
if (!('pkgdown' %in% pkgs)) { install.packages('pkgdown') }
if (pkg_name %in% pkgs) { remove.packages(pkg_name) }
  1. Set working directory and clean files that will be regenerated. This folder will vary based on where the repo was cloned.
setwd(pkg_path)
unlink(c('./man', './inst/doc', './NAMESPACE'), recursive = T)
  1. Run the pre-build checks
devtools::check(manual = T, vignettes = T)
detach(pos = which(search() == pkg_pkg), unload = T)
unlink(c('./man', './NAMESPACE'), recursive = T)
  1. Make docs
devtools::document()
devtools::build_vignettes()
dir.create('./inst/doc', showWarnings = F, recursive = T)
files <- list.files('./doc', pattern = 'html')
lapply(files, function(x) { file.rename(paste0('./doc/', x), paste0('./inst/doc/', x)) } )
unlink(c('./doc', './Meta'), recursive = T)
detach(pos = which(search() == pkg_pkg), unload = T)
  1. Test the install-ability
devtools::install_local(upgrade = 'never')
remove.packages(pkg_name)
  1. Run the tests
devtools::test()
  1. Test using CRAN like resources
rhub::check_for_cran()
devtools::check_win_release()