Quickly set up your new R package with usethis

I recently discovered the R package usethis which allows to quickly set up common components of an R package. If you are creating a lot of R packages this is definitely something you should look into.

Creating a new package skeleton is as easy as usethis::create_package("path/to/package"). If you are in RStudio this will automatically open a new RStudio project for your package with the necessary components (folder R, DESCRIPTION file etc.).

Afterwards you can add further useful components with usethis. This is what I run:

options(
  usethis.description = list(
    `Authors@R` = 'person("Your", "Name", email = "youremail", role = c("aut", "cre"))',
    License = "MIT + file LICENSE"
  )
)

usethis::use_roxygen_md()
usethis::use_mit_license("Your Name")
usethis::use_readme_rmd()
usethis::use_pipe()
usethis::use_news_md()
usethis::use_pkgdown()
usethis::use_description_defaults()
usethis::use_test()
usethis::use_git()

Then you can start creating R scripts and adding and commiting your functions.

What you still need to do is connect your local Git repository to your Github repository. Just create a repository on Github and then run in your terminal in RStudio (assuming you have already committed files):

git remote add origin https://github.com/username/repo.git
git push -u origin master
Contents