Portable, personal packages

[This article was first published on Deciphering life: One bit at a time :: R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Portable, personal packages

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

To leave a comment for the author, please follow the link and comment on their blog: Deciphering life: One bit at a time :: R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)