
There are some packages that need to be installed before we start developing.

Throughout these notes, I will present only the Rstudio version of package development, but package development can also be done using the command line (though there is really no reason to do this, as Rstudio makes the whole process much easier). Here I will walk through the process of writing a very simple R package, uploading it to GitHub, and downloading it from GitHub. Packages can uploaded and downloaded from GitHub, or even just built for personal use (some R users have their own personal R packages with documented functions that they have written and regularly use in their own research). But not every R package is or should be uploaded to CRAN. Packages on CRAN are published for the R community and installed in RStudio using the function install.packages. Even if you never intend to do this for your own code, I hope that this process will make you more familiar with the R packages that you use in your research, and how those packages are made.Ī lot of R users are probably familiar with the Comprehensive R Archive Network (CRAN), a massive repository that currently holds over 13000 published R packages. In these notes, I will walk you through the basics of writing your own R package. If you have been using R for even a short length of time, you have probably needed to install and use the functions published in an R package. R Packages can serve any number of uses, and range from well documented and widely used statistical libraries to packages of functions that tell knock-knock jokes. Packages are bundles of code and data that can be written by anyone in the R community.


After going through this tutorial, you will be able to write a basic R package, which can be installed from Github. Our Coding Club would like to extend our deepest gratitude to them, for allowing us to publish this tutorial on our website as well. This tutorial was originally created by the University of Stirling’s Coding Club, and can be found at this link.
