Portable, Personal Packages

R packages development

My take on creating simple little packages for your own commonly used functions.

Robert M Flight

ProgrammingR had an interesting post recently about keeping a set of R functions that are used often as a gist on Github, and sourceing that file at the beginning of R analysis scripts. There is nothing inherently wrong with this, but it does end up cluttering the user workspace, and there is no real documentation on the functions, and no good way to implement unit testing.

However, the best way to have sets of R functions is as a package, that can then be installed and loaded by anyone. Normally packages are compiled and hosted on CRAN, R-forge, or Bioconductor. However, Github is becoming a common place to host packages, and thanks to Hadley Wickham’s install_github function in the devtools package, it is rather easy to install a package directly from Github. This does require that you have r-tools installed if you are using Windows (I know that can take a bit of work, but it’s not impossible), and do some extra work to create a proper package, but the overhead is probably worth it if you are using these functions all the time.

Once you have the package created and hosted on Github, it is simple to install it once, and load it when needed. If there is a particular version of the package that is required, it is even possible to tell install_github to install a particular version based on the commit, or a tag.

Some examples of this type of package can be found on Github: 1 2 3


If you see mistakes or want to suggest changes, please create an issue on the source repository.


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/rmflight/researchBlog_distill, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Flight (2013, Sept. 23). Deciphering Life: One Bit at a Time: Portable, Personal Packages. Retrieved from https://rmflight.github.io/posts/2013-09-23-portable-peronal-packages/

BibTeX citation

  author = {Flight, Robert M},
  title = {Deciphering Life: One Bit at a Time: Portable, Personal Packages},
  url = {https://rmflight.github.io/posts/2013-09-23-portable-peronal-packages/},
  year = {2013}