4  Set up your environment

To build an R package you will need R installed and an IDE: preferably R Studio or Positron.

There are some packages that you will need devtools and usethis they are key to follow the different steps on this package building tutorial.

install.packages("pak")
library(pak)
pkg_install("usethis")
pkg_install("devtools")

To work with the omopverse, you will also need to install the omopgenerics package. Alongside with other packages that may be useful:

You can see the list of the omopverse packages in our website.

4.1 Create an empty package

To create an empty package you can do it with usethis:

library(usethis)

create_package(path = "path/to/folder")

The package will be named by the name of the folder.

4.2 Add a license

Adding licenses is very important so you are protected and users how they can use your product in general we release using the Apache 2.0 license, but if you prefer there are other options such as:

  • More permissive:

    • MIT: simple and permissive.
    • Apache 2.0: MIT + provides patent protection.
  • Copyleft:

    • GPL v2: requires sharing of improvements.
    • GPL v3: requires sharing of improvements.
    • AGPL v3: requires sharing of improvements.
    • LGPL v2.1: requires sharing of improvements.
    • LGPL v3: requires sharing of improvements.
  • Creative commons licenses appropriate for data packages:

    • CC0: dedicated to public domain.
    • CC-BY: Free to share and adapt, must give appropriate credit.

you can add a license easily with usethis:

use_apl2_license()

This will add the LICENSE.md file and populate the DESCRIPTION file with the relevant license field.

4.3 Set up GitHub

GitHub actions are very useful to ensure the continuous integration workflow. The fifth part of the book is dedicated to GitHub and GitHub Actions at that stage you will learn how to use github for: