# “sinkr” – a collection of functions featured on “me nugget”

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The R package **me nugget**, 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.

**(version 1.0) has now been released: https://github.com/menugget/sinkr**

*sinkr*I have finally gotten around to learning how to create an R package and decided to start by bundling functions that I have featured on the blog. Thanks to the R Studio team for making this so easy (in combination with the R packages roxygen2 and devtools). In addition to the great tips on the R Studio website, I found the following Youtube videos helpful along the way:

- Create an R Package in RStudio (Basic package creation)
- Creating RStudio projects from GitHub Repositories (especially the tip to use the SSH clone URL link rather than HTTPS)

*sinkr*), I’m not confident to upload this to CRAN. But, one can easily install the package using devtools and the following code (see https://github.com/hadley/devtools for OS-specific package updating tips):

library(devtools)

install_github(“sinkr”, “menugget”)

For those using functions that were featured on this site in the past, the present versions may differ slightly, especially in the case of function names. For example, function names like plot.stacked were getting associated with the general plot function during the package build and thus “.” characters have been removed from all function names (e.g. plotStacked).

*sinkr*functions include:

- addAlpha – Add alpha channel (transparency) to colors
- bioEnv – Clarke and Ainsworth’s BIO-ENV routine
- bvStep – Clarke and Ainsworth’s BVSTEP routine
- cov4gappy – Covariance matrix calculation for gappy data (used by eof)
- dineof – Data Interpolating Empirical Orthogonal Functions
- earthBear – Directional bearing between two geographic locations
- earthDist – Earth distance between two geographic locations
- eof – Empirical Orthogonal Functions analysis (specifically for gappy data)
- eofRecon – EOF reconstruction
- expmat – Exponentiation of a matrix
- gmtColors – Generic Mapping Tools (GMT) palette colors
- imageScale – Make a color scale to accompany an image or other plot
- jetPal – “jet” palette
- lonLatFilter – Filter lon/lat positions that fall within defined boundaries
- matrixPoly – Make polygons from a matrix
- nearest – Calculate the nearest element in a vector as compared to a reference value
- newLonLat – Directional bearing between two geographic locations
- plotStacked – Stacked plot
- plotStream – Stream plot
- round2reso – Round to defined resolution increment
- spirographR – Make a sprirograph-like design
- val2col – Convert values to color levels

I can recommend package creation to anyone who wants greater control and clearer documentation of functions. I also used to do a lot of numbering of R scripts to keep track of versions (e.g. “plotstacked.03.R”). R studio combined with GitHub has been a real revelation to me in this regard (thanks to Tal Galili for the final nudge!: http://datascience.la/a-conversation-with-tal-galili-at-user-2014/).

I hope that future function examples will be easier to reproduce through simple loading of the

*sinkr*package.

To

**leave a comment**for the author, please follow the link and comment on their blog:**me nugget**.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.