Final steps

Developing R Packages

Jasmin Ludolf

Content Developer

R package structure

R package skeleton

Developing R Packages

Package versions

Example: tidyr 1.3.0

  • Format: <major>.<minor>.<patch>.<dev>
  • Default: 0.0.0.9000
  • 9000: package in development
Developing R Packages

Package version incrementing guidelines

Format: <major>.<minor>.<patch>.<dev>

  • dev: rarely changed, remove for release
  • patch: changed for bug fixes
    • More bugs before functionality change
  • minor: small additional functionality added to package before initial release
    • patch number reset to 0
  • major: package considered stable to release
    • From 1.5.3 to 2.0.0 : old code could break

 

  • Not in development: 0.0.0.9000 -> 0.0.0
  • One bug fixed: 0.0.1
  • One more bug fixed: 0.0.2
  • Additional functionality: 0.1.0

 

  • Stable for release: 1.0.0
  • Big changes: 2.0.0
Developing R Packages

Update title, author, version, and description

Package: unitConverter
Title: What the Package Does (One Line, Title Case)

Version: 0.0.0.9000
Authors@R: person("First", "Last", , "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "YOUR-ORCID-ID"))
Description: What the package does (one paragraph).
Package: unitConverter
Title: Unit Conversion Utilities for Distance, 
    Time, Weight, and Temperature

Version: 0.1.0
Authors@R: person("Jasmin", "Ludolf", , "[email protected]", role = c("aut", "cre"))
Description: The `unitConverter` package provides a collection of utility functions for converting distance, time, weight, and temperature values. It offers seamless conversion between various units within each category, allowing users to easily transform measurement data.
Developing R Packages

Documenting a data file

use_r("temperature_data")

Edit R/temperature_data.R:

#' Temperature values and units
#'

#' Temperature values and corresponding unit (Celsius, Fahrenheit, or Kelvin)
#' @format Data frame with two columns and 1000 rows
#' \describe{ #' \item{value}{Numeric temperature value.} #' \item{unit}{Temperature unit.} #' }
#' @examples #' temperature_data
"temperature_data"
roxygenize()
Developing R Packages

What does devtools::check() look for?

devtools::check()

  • Can the package be installed
  • DESCRIPTION information is correct
  • Package dependencies
  • Syntax errors in code
  • Complete documentation
  • Successful tests running
  • Successful vignettes building

Checkmark

Developing R Packages

Running devtools::check()

unitConverter check GIF

Developing R Packages

Let's practice!

Developing R Packages

Preparing Video For Download...