Showing posts with label roxyPackage. Show all posts
Showing posts with label roxyPackage. Show all posts

R package development

Building R packages is not particular hard, but it can be a bit of a daunting endeavour at the beginning, particularly if you are more of a statistician than a computer scientist or programmer.

Some concepts may appear foreign or like red tape, yet many of them evolved over time for a reason. They help to stay organise, collaborate more effectively with others and write better code.

So, here are my slides of the R package development workshop at Lancaster University.

R package development

For a detailed and authoritative reference on R package development see the Writing R Extensions manual on CRAN.

Create an R package from a single R file with roxyPackage

Documenting code can be a bit of a pain. Yet, the older (and wiser?) I get, the more I realise how important it is. When I was younger I said 'documentation is for people without talent'. Well, I am clearly loosing my talent, as I sometimes struggle to understand what I programmed years ago. Thus, anything that soothes the pain of writing and maintaining documentation must be good and should help me to better understand my 'old me' in the future.

Ideally I want my R code and documentation in as few files as possible. A good start to achieve this is using roxygen2, an R package which has been around for some time. It allows me to tie R code together with the documentation in the same file and helps considerably in maintaining R packages.

The roxyPackage by Meik Michalke goes a step further, building on roxygen2. Meik presented his package at the Cologne R user group meeting a few weeks ago and I was intrigued by it. As I said in my notes to the meeting, with roxyPackage I can create a package from a single file of R code and documentation.

Here is an example of one R file to build a package using roxyPackage. For my toy example I wrote a doughnut plot function in R, something which is clearly missing ;)


I took the basic pie chart function and amended it to plot another white disc in the middle. On top of the function code I wrote the help file documentation using the roxygen2 syntax.
Read more »

Review: Kölner R Meeting 6 February 2013

The fourth Cologne R user meeting took place last Wednesday at the Institute of Sociology. Thanks to Bernd Weiß for hosting the event and Revolution Analytics for their sponsorship.

We had two fantastic talks by Klaus Jacobi and M.eik Michalke. Klaus talked about Eliminating cloud pixels in satellite images via chronological interpolation and Meik presented his new roxyPackage package, which makes it even easier to maintain R packages with roxygen2.

Eliminating cloud pixels in satellite images via chronological interpolation

Klaus gave a great case study about his consulting work as a water engineer in Asia, where he used R to analyse the snow melting process in the mountains of Pakistan.

Images of snow melting over time. Klaus Jacobi

About half of the fresh water in some regions of Pakistan is sourced from snow meting during the spring season. The water is captured in dams and as the snow only melts slowly the water supply is much more predictable than the water from the monsoon season, which is the other key source of fresh water during the year.
Read more »