r
usethis::create_package("~/mypkg")
usethis::use_mit_license("Author Name") # CRAN
# OR: License: Artistic-2.0 # Bioconductor standard
usethis::use_testthat()
usethis::use_vignette("introduction")
usethis::use_readme_md()
usethis::use_news_md()
Required: DESCRIPTION, NAMESPACE, LICENSE, NEWS.md, README.md, .Rbuildignore, .gitignore
Authors@R: use person() with aut, cre roles + ORCID:: or importFromrequireNamespace() guard in code0.99.0 for new submissionsbiocViews: required (e.g., Genetics, Sequencing, QualityControl)LazyData: false (Bioconductor requirement)VignetteBuilder: knitrNever use in R/ files:
ForbiddenUse insteadlibrary() / require()``:: or @importFrom``T / F``TRUE / FALSE``sapply()``vapply() (type-safe)1:length(x)``seq_along(x) / seq_len(n)``cat() / print()``message() (except in show methods)options() / par()Never modify global state@slot direct accessUse accessor generics<<<-Never use global assignmentset.seed() / browser()Remove before submission
Every @export function must have:
@param for all arguments@return describing the return value@examples that run in <5 seconds@references with DOIs for methods: \doi{10.xxxx/yyyy}Use \donttest{} for slow examples. Never \dontrun{}.
For infrastructure packages extending Bioconductor classes:
r
# Define generic — this is the extension point
setGeneric("myFunction", function(x, ...)
standardGeneric("myFunction"))
# Define method for your class
setMethod("myFunction", "MyClass", function(x, ...) {
# implementation
})
Key principle: analytical operations should be generics, not plain functions. This lets downstream packages specialize behavior for their own classes. See references/bioconductor.md.
r
devtools::test() # all tests
covr::package_coverage() # target ≥80%
Test error paths with expect_error(), not just happy paths.
r
rcmdcheck::rcmdcheck(
args = c("--no-manual", "--as-cran"),
error_on = "warning"
)
For Bioconductor, also run:
r
BiocCheck::BiocCheck("pkg_0.99.0.tar.gz", `new-package` = TRUE)
BiocCheck::BiocCheckGitClone(".")
See references/github-actions.md for platform-specific configs.
CRAN packages: use r-lib/actions standard workflow.
Bioconductor packages: use r-lib/actions/setup-r-dependencies
which auto-resolves Bioc deps from DESCRIPTION.
See references/visualization.md for Nature/Science style standards.
Key rules:
theme_classic(), no gridlines, 8pt base fontUpload tarball to https://xmpalantir.wu.ac.at/cransubmit/
Include cran-comments.md. See references/cran.md.
See references/troubleshooting.md for solutions to frequent R CMD check and BiocCheck problems.