Moritz Friedrich, Klemens Kurtz
2018-05-14
Source: revolutionanalytics.com (2017)
A bundle of functions, data sets and help pages that you install in addition to the base R installation.
Source: R-Studio
“Seriously, it doesn’t have to be about sharing your code (although that is an added benefit!). It is about saving yourself time.” Parker (2014)
Source: Wickham (2015)
devtools:
devtools package: a suite of R functions to automate common development tasks.
devtools protects you from many potential mistakes, so you can focus on the problem you're interested in, not on developing a package.
Cheatsheet: R-Studio > Help > Cheatsheets > Package Development with devtools
Source: Wickham (2015)
Why use Git + GitHub?
install.packages("devtools")
devtools::install_github("username/packagename")
Source: Wickham (2015)
Source: Wickham (2015), CRAN
A package is a convention for organizing files into directories.
Source: Wickham (2015), R-Studio
install.packages(c("devtools", "roxygen2", "testthat", "knitr"))
# Check:
#install.packages("rstudioapi")
rstudioapi::isAvailable("0.99.149") # TRUE?
You’ll also need a C compiler and a few other command line tools. If you’re on Windows or Mac and you don’t already have them, RStudio will install them for you. Otherwise:
Source: Wickham (2015)
Source: Wickham (2015)
Imports:
dplyr (>= 0.4.0),
ggvis (>= 0.2)
Suggests:
knitr (>= 0.1.0)
Source: Wickham (2015)
#' Add together two numbers.
#'
#' @param x A number.
#' @param y A number.
#' @return The sum of \code{x} and \code{y}.
#' @examples
#' add(1, 1)
#' @export
Source: Wickham (2015)
Source: Wickham (2015)
Source: Wickham (2015)
Source: Wickham (2015)
CRAN - Creating R packages: https://cran.r-project.org/doc/manuals/R-exts.html#Creating-R-packages
Our slides: https://github.com/kklamsi/howToPackage