05:00
R/Pharma Conference 2025
Data visualisation specialist, mainly using R, Python, and D3.
Background in statistics, operational research, and data science.
Author of several R packages, mainly for visualisation.

Combines slides, live coding examples, and exercises for you to participate in.
Ask questions throughout!
Access to R environment:
Packages:
A collection of (some of) the following:
that are arranged in a specific structure.
Building a package makes it easier to:

Source: giphy.com
These are myths.

cookbook/
├─ DESCRIPTION

cookbook/
├─ DESCRIPTION
├─ R/
│ ├─ tomato-bread.R
│ ├─ blueberry-muffins.R

cookbook/
├─ DESCRIPTION
├─ R/
│ ├─ tomato-bread.R
│ ├─ blueberry-muffins.R
├─ man/
│ ├─ tomato-bread.Rd
│ ├─ blueberry-muffins.Rd

cookbook/
├─ DESCRIPTION
├─ R/
│ ├─ tomato-bread.R
│ ├─ blueberry-muffins.R
├─ man/
│ ├─ tomato-bread.Rd
│ ├─ blueberry-muffins.Rd
├─ NAMESPACE

cookbook/
├─ DESCRIPTION
├─ R/
│ ├─ tomato-bread.R
│ ├─ blueberry-muffins.R
├─ man/
│ ├─ tomato-bread.Rd
│ ├─ blueberry-muffins.Rd
├─ NAMESPACE
├─ data/
├─ pkgdown/
├─ tests/
├─ vignettes/
├─ vignettes/
├─ README.md
├─ NEWS.md

usethis is an R package that automates repetitive tasks that arise during project setup and development, both for R packages and non-package projects.

library()package::function() a few timesDESCRIPTION (metadata) file05:00
usethis::create_package("cookbook")DESCRIPTION fileusethis::use_mit_license()devtools::install() do?.R fileR/ foldergenerate_hex() function to the packagedevtoolsinstall()
load_all()
devtools::load_all()generate_hex() work now?05:00
devtools::load_all() and test it worksIf you need a function:
roxygen2 to do that

#' @export tagsWhat happens when you run ?ggplot2::geom_point?
Where does all that stuff come from?
roxygen2There are lots of different options for roxygen tags, the most common:
export: exports the functionparam: what does an argument do? what are the defaults?returns: what type of object does the function return?examples: show the function in actiondevtools::document()05:00
roxygen2 to export your functiondevtools::document()Is it ready to share with someone else?
There are different types and levels of tests:
1 error ✖ | 1 warning ✖ | 2 notes ✖import, importFrom, namespacing)usethis::use_package("stringr")05:00
If you need a function:
You can add your package to CRAN so that other can install it using install.packages("cookbook").
But CRAN is NOT the only way to share packages:
devtools (or remotes or pak) to install if it’s not on CRAN
devtools::install_local("cookbook")devtools::install_github("username/cookbook")If you’re not (yet) comfortable with using Git and GitHub, you can still upload the package files using Add file -> Upload files.
Git can help with managing versions of packages.
See happygitwithr.com for help getting started.
pkgdown
Vignettes:
R for Data Science (Functions): r4ds.hadley.nz/functions.html
R Packages: r-pkgs.org
Data science resources: nrennie.rbind.io/data-science-resources

Source: giphy.com