More package structure

Developing R Packages

Jasmin Ludolf

Content Developer

Advantages of packages over scripts

  • Better organization
  • Facilitate reproducibility
  • Enable easier collaboration
  • Simplify sharing and distribution

Collaboration

Developing R Packages

Structuring code in the R directory

The R/ directory:

  • Contains all R script package script files
  • Scripts should be .R files
  • Separate functions into different R scripts

R directory highlight

Developing R Packages

Choose a valid package name

  • ASCII letters, numbers, and periods
  • At least two characters
  • Start with a letter
  • Cannot end with a dot
  • _ is not a valid character

 

CRAN: central repository for R packages

1 Writing R Extensions from CRAN: https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Creating-R-packages
Developing R Packages

The available package

library(available)

available("yourPackageName")

Checks for

  • Valid package name
  • Package name available on CRAN
  • Positive or negative sentiment
Developing R Packages

available() output

available("horrendous")

horrendous checking output

Developing R Packages

Choose an informative package name

Examples:

  • readr: play on "reader"
  • tidyr: large role in tidying data

Examples of uninformative package names:

  • MASS: obscure, reference to textbook
  • utils: generic, lacks insight
Developing R Packages

Licensing our package

MIT

use_mit_license()

MIT License output

  • Requires inclusion of original copyright notice
  • Primarily used for software

CC0

use_cc0_license()

CC0 License output

  • Does not require inclusion of original copyright notice
  • Used for a variety of works, including software, datasets, text, and images
Developing R Packages

Let's practice!

Developing R Packages

Preparing Video For Download...