4.4 Creating a new package

  • Call usethis::create_package('yourPackageName')
  • In RStudio, do File > New Project > New Directory > R Package. This ultimately calls usethis::create_package(), so really there’s just one way.

(I prefer to use RStudio - show using create_package from bash)

4.4.1 What does this do?

This creates your project structure for you:

  • R/ directory
  • DESCRIPTION file
  • NAMESPACE file
  • pkgName.Rproj file
  • .Rbuildignore & .gitignore

DO NOT use package.skeleton() - it creates a package which will lead to errors when running R CMD build and is not consistent with the devtools style of development.

4.4.2 Where to put this package?

This is distinct from where your R packages are installed. It makes sense to put this in a similar area to where you keep your other R projects.

Within my /user/documents/, I have R_projects/ and R_pkgs/