# Tutorials

### Connecting the real world to R with an Arduino

October 2, 2012 |

If connecting data to the real world is the next sexy job, then how do I do this? And how do I connect the real world to R? It can be done as Matt Shottwell showed with his home made ECG and a patched version of R at useR! 2011. However, ... [Read more...]

### Using R in Insurance at GIRO 2012

September 17, 2012 |

Every year the UK’s general insurance actuarial community organises a big conference, which they call GIRO, short for General Insurance Research Organising committee. This year's conference is in Brussels from 18 - 21 September 2012. Despite the fac... [Read more...]

### Interactive web graphs with R – Overview and googleVis tutorial

September 5, 2012 |

Today I feel very lucky, as I have been invited to the Royal Statistical Society conference to give a tutorial on interactive web graphs with R and googleVis. I prepared my slides with RStudio, knitr, pandoc and slidy, similar to my Cambridge R talk. ... [Read more...]

August 21, 2012 |

In this tutorial I am going to share my R&D and trading experience using the well-known from statistics Autoregressive Moving Average Model (ARMA). There is a lot written about these models, however, I strongly recommend Introductory Time Series with R, which I find is a perfect combination between light ... [Read more...]

### plotting raster data in R: adjusting the labels and colors of a classified raster

August 2, 2012 |

Thank’s to Andrej who wrote this comment: “Is it possible to to color the resulting 12 clusters within your original image to get a feel for visual separation?” You can do so: But how to get values at a location? You will need these values to determine whether the defined ... [Read more...]

### unsupervised classification of a Landsat image in R: the whole story or part two

August 1, 2012 |

The main question when using remote sensed raster data, as we do, is the question of NaN-treatment. Many R functions are able to use an option like rm.NaN=TRUE to treat these missing values. In our case the kmeans function in R is not capable to use such a ... [Read more...]

### Rook rocks! Example with googleVis

August 1, 2012 |

What is Rook?Rook is a web server interface for R, written by Jeffrey Horner, the author of rApache and brew. But unlike other web frameworks for R, such as brew, R.rsp (which I have used in the past1), Rserve, gWidgetWWWW or sumo (which I haven't used...

### Split-plot 2: let’s throw in some spatial effects

July 30, 2012 |

Disappeared for a while collecting frequent flyer points. In the process I ‘discovered’ that I live in the middle of nowhere, as it took me 36 hours to reach my conference destination (Estoril, Portugal) through Christchurch, Sydney, Bangkok, Dubai, Madrid … Continue reading → [Read more...]

### unsupervised classification of a raster in R: the layer-stack or part one.

July 29, 2012 |

In my last post I was explaining the usage of QGis to do a layerstack of a Landsat-scene. Due to the fact that further research and trying out resulted in frustration I decided to stick with a software I know well: R. So download the needed layers here and open ... [Read more...]

### Modeling Trick: Impact Coding of Categorical Variables with Many Levels

July 23, 2012 |

One of the shortcomings of regression (both linear and logistic) is that it doesn’t handle categorical variables with a very large number of possible values (for example, postal codes). You can get around this, of course, by going to another modeling technique, such as Naive Bayes; however, you lose ... [Read more...]

### introduction to R: learning by doing (part 2: plots)

July 10, 2012 |

Lets go one with the second part of learning R by doing R (you will find the first part here. As we have used vectors, matrices and loops in the first part, we will concentrate on graphics in this one. but first we will need data to plot: Sometimes you ... [Read more...]

### introduction to R: learning by doing (part 1)

July 9, 2012 |

Geography is often about statistics as it is the basis for fast exchange of information: providing a mean and standard deviation to the audience is often much easier then showing raw data: Learning a script language for this purpose can be a hard-ass work. But I think it is more ... [Read more...]

### Applying a function successively in R

July 3, 2012 |

At the R in Finance conference Paul Teetor gave a fantastic talk about Fast(er) R Code. Paul mentioned the common higher-order function Reduce, which I hadn't used before. Reduce allows me to apply a function successively over a vector. What does that...

July 1, 2012 |

A primary problem data scientists face again and again is: how to properly adapt or treat variables so they are best possible components of a regression. Some analysts at this point delegate control to a shape choosing system like neural nets. I feel such a choice gives up far too ... [Read more...]

### reproducible documents/analytics in R: the knitr package

June 26, 2012 |

When I am working in new institutions and I am asking: “Do you have a document management system?” I often get the answer:”Yap, we are using folders” … OKAY. Making analysis, developing applications and keeping an eye on code, data and applications make this even harder as it has to ... [Read more...]

### Hodgkin-Huxley model in R

June 24, 2012 |

One of the great research papers of the 20th century celebrates its 60th anniversary in a few weeks time: A quantitative description of membrane current and its application to conduction and excitation in nerve by Alan Hodgkin and Andrew Huxley. Only a...

### reading shape files in R

June 24, 2012 |

If I would like to adjust a shape file I normally used the way over an excel file or a text file to get a table and to join this with an existing shape file. Due to the sp and rgdal packages in R you can manipulate shapefiles directly in ... [Read more...]

### setting your working directory permanently in R

June 24, 2012 |

Most of us R users are using a special working directory for the daily work in R. But I was bothered in typing everytime in my command line prior using R. Also using this line at the first position in scripts was not pleasent enough. So how to get around ... [Read more...]

### How to outrun a crashing alien spaceship

June 11, 2012 |

Hollywood movies are obsessed with outrunning explosions and outrunning crashing alien spaceships. For explosions the movies give the optimal (but unusable) solution: run straight away. For crashing alien spaceships they give the same advice, but in this case it is wrong. We demonstrate the correct angle to flee. Running from ... [Read more...]

### Transforming subsets of data in R with by, ddply and data.table

June 11, 2012 |

Transforming data sets with R is usually the starting point of my data analysis work. Here is a scenario which comes up from time to time: transform subsets of a data frame, based on context given in one or a combination of columns.As an example I use ...