10 January 2018
RStudio: https://www.rstudio.com/
CRAN: https://cran.r-project.org/mirrors.html
BioConductor: http://www.bioconductor.org/
MetaCRAN: https://www.r-pkg.org/
R Package Documentation: https://rdrr.io/
Quite tricky to answer! I would say:
a set of files that passes the
R CMD install
2012: article by Kurt Hornik (CRAN maintainer) http://www.stat.tugraz.at/AJS/ausg121/121Hornik.pdf
package.skeleton()
https://cran.r-project.org/doc/manuals/r-release/R-exts.html
https://support.rstudio.com/hc/en-us/articles/200486488-Developing-Packages-with-RStudio
Must read: http://r-pkgs.had.co.nz/
DESCRIPTION
: meta data of your package (name, version, …)NAMESPACE
: import / export / dynlabR
: R functionsman
: documentation (.Rd
files)data
: R objects stored as RData (.rda
)vignettes
: documentationsrc
: file in other programming languagetest
: tests for you packageinst
: CITATION / non-R scripts / external-data….Rbuildignore
.Rinstignore
DESCRIPTION
: meta data of your package (name, version, …)NAMESPACE
: import / export / dynlabR
: R functionsman
: documentation (.Rd
files)test
: tests (.R
files)data
: data (.Rda
files)install.packages('devtools')
devtools
load_all()
document()
test()
load_all()
First, create a function. For instance I’ve created:
getDigits <- function(x, collapse = NULL) { out <- strsplit(x, split = "\\D") %>% lapply(function(x) x[x != ""]) if (!is.null(collapse)) out <- lapply(out, paste, collapse = collapse) out }
in R/getDigits.R
file.
load_all()
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-Dependencies
The ‘Suggests’ field uses the same syntax as ‘Depends’ and lists packages that are not necessarily needed. This includes packages used only in examples, tests or vignettes (see Writing package vignettes), and packages loaded in the body of functions. E.g., suppose an example11 from package foo uses a dataset from package bar. Then it is not necessary to have bar use foo unless one wants to execute all the examples/tests/vignettes: it is useful to have bar, but not necessary. Version requirements can be specified but should be checked by the code which uses the package.
Finally, the ‘Enhances’ field lists packages “enhanced” by the package at hand, e.g., by providing methods for classes from these packages, or ways to handle objects from these packages (so several packages have ‘Enhances: chron’ because they can handle datetime objects from chron even though they prefer R’s native datetime functions). Version requirements can be specified, but are currently not used. Such packages cannot be required to check the package: any tests which use them must be conditional on the presence of the package. (If your tests use e.g. a dataset from another package it should be in ‘Suggests’ and not ‘Enhances’.)