More package structure

R-Pakete entwickeln

Jasmin Ludolf

Content Developer

Advantages of packages over scripts

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

Collaboration

R-Pakete entwickeln

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

R-Pakete entwickeln

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
R-Pakete entwickeln

The available package

library(available)

available("yourPackageName")

Checks for

  • Valid package name
  • Package name available on CRAN
  • Positive or negative sentiment
R-Pakete entwickeln

available() output

available("horrendous")

horrendous checking output

R-Pakete entwickeln

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
R-Pakete entwickeln

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
R-Pakete entwickeln

Let's practice!

R-Pakete entwickeln

Preparing Video For Download...