Skip to contents

Why do I need to build my own package?

Packaging our functions in R packages. Why should I do it?

  • is easily executable and shareable code
  • makes reusable R functions
  • includes documentation that describes how to use them
  • makes reproducible R code

How to create an R package in 4 simple steps

  1. Define the working directory
filepath <- "C:/Users/pavla/Nextcloud/GitKraken/IMS-software/ToyPackage"
  1. Create r package folder
usethis::create_package()  
  1. Copy in R folder the functions of the r package
setwd(filepath)
devtools::document()
devtools::load_all() 
  1. Build and check the package
devtools::build(pkg = filepath, path = NULL, binary = FALSE, manual = TRUE)
devtools::check_built(path = filepath, cran=TRUE, manual = TRUE)
devtools::build_manual(pkg = filepath, path = NULL)