| name | cran-submission |
| description | Complete guide to CRAN submission including policies, pre-submission checks, common issues, and the submission process |
CRAN Submission Guide
This skill covers the complete CRAN submission process, from pre-submission preparation through to acceptance and post-release tasks. CRAN (Comprehensive R Archive Network) is the primary repository for R packages and has strict quality requirements.
Rules
- All exported functions must have
@returns and @examples documentation
- Version number must be greater than the current CRAN version
- Test on multiple platforms before submission (Windows, macOS, Linux, R-devel)
- Fix all ERRORs and WARNINGs - CRAN will reject packages with any
- NOTEs should be explained in cran-comments.md
- Title case for Title field with no period at the end, under 65 characters
- Use cph role for copyright holders in Authors@R
- Check all URLs with urlchecker::url_check()
- Examples must run without errors (use
\donttest{} sparingly)
- Respond to CRAN within 2 weeks or submission will be archived
Pre-Submission Checklist
Essential Documentation Requirements
Every exported function must have:
my_function <- function(x, y) {
}
Critical: Use @returns (not @return) for consistency with roxygen2 7.0+.
DESCRIPTION File Requirements
Package: packagename
Title: A Package That Does Amazing Things # Title case, < 65 chars, no period
Version: 0.1.0 # Must be > current CRAN version
Authors@R: c(
person("First", "Last", email = "email@example.com",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0000-0000-0000")),
person("Another", "Author", role = "aut"),
person("Company Name", role = "cph") # Copyright holder
)
Description: Provides tools for amazing analysis. This package implements
novel algorithms and provides intuitive interfaces. Functions include
data processing, visualization, and reporting capabilities.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.0
URL: https://username.github.io/packagename/, https://github.com/username/packagename
BugReports: https://github.com/username/packagename/issues
Suggests:
testthat (>= 3.0.0),
knitr,
rmarkdown
VignetteBuilder: knitr
Config/testthat/edition: 3
Title field rules:
- Title case (capitalize major words)
- No period at end
- Under 65 characters
- Don't start with "A Package for..." (redundant)
- Be specific about what it does
Description field rules:
- One paragraph
- Indent continuation lines with 4 spaces
- Don't start with "This package..."
- Explain what the package does, not just list features
- Mention key algorithms or papers if relevant
Version Numbering
For new submissions:
Version: 0.1.0
For updates (must be > CRAN version):
# If CRAN has 0.1.0, use:
Version: 0.1.1 # Bug fixes
Version: 0.2.0 # New features
Version: 1.0.0 # Major release
Development versions (not for CRAN):
Version: 0.1.0.9000 # Development version after 0.1.0
Multi-Platform Testing
Local Testing
devtools::check()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check(args = c('--as-cran'))
Windows Testing
devtools::check_win_devel()
devtools::check_win_release()
devtools::check_win_oldrelease()
You'll receive an email with results in ~30 minutes.
R-hub Testing
install.packages("rhub")
rhub::validate_email()
rhub::check_for_cran()
rhub::check(platform = "windows-x86_64-devel")
rhub::check(platform = "ubuntu-gcc-release")
rhub::check(platform = "macos-highsierra-release-cran")
rhub::check(platform = "solaris-x86-patched")
rhub::platforms()
Note: R-hub can be unreliable. GitHub Actions with r-lib/actions is often more reliable.
GitHub Actions
Most reliable multi-platform testing:
usethis::use_github_action("check-standard")
Tests on:
- macOS (release)
- Windows (release)
- Ubuntu (devel, release, oldrel-1)
URL Checking
urlchecker::url_check()
Common issues:
- DOIs should use
https://doi.org/ not http://dx.doi.org/
- Use permanent URLs, not redirects
- Some URLs may be temporarily down (explain in cran-comments.md)
Creating cran-comments.md
Create cran-comments.md in package root:
## Test environments
* local R installation, R 4.4.0
* ubuntu 22.04 (on GitHub Actions), R-devel, R-release, R-oldrel-1
* windows-latest (on GitHub Actions), R-release
* macos-latest (on GitHub Actions), R-release
* win-builder (devel and release)
## R CMD check results
0 errors | 0 warnings | 1 note
* This is a new release.
## Downstream dependencies
There are currently no downstream dependencies for this package.
For Updates
## Test environments
* local R installation, R 4.4.0
* ubuntu 22.04 (on GitHub Actions), R-devel, R-release, R-oldrel-1
* windows-latest (on GitHub Actions), R-release
* macos-latest (on GitHub Actions), R-release
## R CMD check results
0 errors | 0 warnings | 0 notes
## What's changed
This is a minor release that fixes bugs and adds new features:
* Fixed issue with X (#123)
* Added new function Y
* Improved documentation for Z
## Downstream dependencies
I have run R CMD check on downstream dependencies of my package.
All packages passed.
Explaining NOTEs
## R CMD check results
0 errors | 0 warnings | 1 note
* Checking CRAN incoming feasibility ... NOTE
Maintainer: 'First Last <email@example.com>'
New submission
Possibly misspelled words in DESCRIPTION:
MCMC (3:49)
PyMC (9:31)
These are not misspelled:
* MCMC is a standard acronym for Markov Chain Monte Carlo
* PyMC is the name of a Python library
Submission Process
First Submission
devtools::check()
devtools::check_win_devel()
rhub::check_for_cran()
urlchecker::url_check()
devtools::build()
devtools::submit_cran()
Manual Submission
If submit_cran() doesn't work:
- Build package:
devtools::build()
- Go to https://cran.r-project.org/submit.html
- Upload .tar.gz file
- Fill in maintainer email and comments
- Submit
Confirmation Email
You'll receive an email asking to confirm submission:
- Click the confirmation link within 24 hours
- CRAN will then review your package
CRAN Review Process
Timeline
- Submission: Upload package
- Confirmation (immediate): Confirm via email
- Automated checks (minutes to hours): CRAN runs checks
- Human review (days to weeks): CRAN volunteer reviews
- Acceptance or rejection: Email notification
Typical timeline: 1-2 weeks, but can be longer during busy periods.
Common Rejection Reasons
- ERRORs or WARNINGs in R CMD check
- Missing documentation (no @returns or @examples)
- Examples fail or take too long (>5 seconds per example)
- License issues (incompatible or missing LICENSE file)
- DESCRIPTION problems (title, description formatting)
- Failed tests on CRAN's systems
- Large package size (>5 MB without justification)
- Writing to user's home directory without permission
- Internet resources without checks (must fail gracefully if offline)
- Non-standard file permissions
Common R CMD Check Issues and Fixes
1. Undefined Global Variables
Problem:
checking R code for possible problems ... NOTE
my_function: no visible binding for global variable 'x'
my_function: no visible binding for global variable 'y'
Cause: Using NSE (non-standard evaluation) with dplyr, data.table, etc.
Solution:
utils::globalVariables(c("x", "y", "z"))
library(dplyr)
my_function <- function(df) {
df %>%
mutate(z = .data$x + .data$y)
}
2. Unused Imports
Problem:
checking dependencies in R code ... NOTE
Namespace in Imports field not imported from: 'package'
Solution: Remove from DESCRIPTION or use somewhere:
3. Non-ASCII Characters
Problem:
checking R files for non-ASCII characters ... NOTE
Solution: Use Unicode escapes:
"Müller"
"M\u00fcller"
4. Examples Fail
Problem:
checking examples ... ERROR
Solution: Wrap problematic examples:
Rules:
\donttest{}: Runs locally and on CI, skipped on CRAN (for slow examples)
\dontrun{}: Never runs automatically (for examples needing setup)
- Don't overuse - most examples should run
5. Missing Imports
Problem:
checking dependencies in R code ... WARNING
'::' or ':::' imports not declared from:
'package'
Solution: Add to DESCRIPTION Imports and use:
Or declare in NAMESPACE:
importFrom(package, function)
6. LaTeX/PDF Errors
Problem:
checking PDF version of manual ... WARNING
Solution: Fix .Rd formatting issues or use:
build_args: 'c("--no-manual")'
7. Vignette Build Fails
Problem:
checking re-building of vignette outputs ... WARNING
Solution: Ensure vignettes build:
devtools::build_vignettes()
8. File Permissions
Problem:
checking file modes ... NOTE
Solution: Fix permissions:
chmod 644 R/*.R
chmod 644 man/*.Rd
chmod 755 configure
9. Package Size
Problem:
checking installed package size ... NOTE
installed size is X Mb
sub-directories of 1Mb or more:
data Y Mb