Digital Geography

21. May 2015

Overview: R Cheat Sheets

Recently we had a discussion about where to find a nice cheat sheet (No! We are not talking about Simon the Sorcerer walk-throughs). Especially for scripting languages cheat sheets are an excellent way to support your learning attempts and are a handy tool for your every work in data visualisation, automation of tasks and analysis steps. So let’s have a look on R cheat sheets.

R is not S and you might need a Cheat

R is a scripting language which originated from S some years ago and has its roots in statistical computations. It was chosen as an alternative to SPSS and due to its modularity (called packages) you can enhance it quite easy. Nevertheless you might need some reminders for your everyday work and so you will probably look for a nice cheat sheet. A cheat sheet is a condensed help file with the basic syntax and a short explanation for the certain command. Example: The common help for the easy and useful command “strsplit” to separate parts of a string from each other:
Split the Elements of a Character Vector
Description
Split the elements of a character vector <code>x</code> into substrings according to the matches to substring <code>split</code> within them.
Usage
strsplit(x, split, fixed = FALSE, perl = FALSE, useBytes = FALSE)

Arguments
x        character vector, each element of w ....
And as you can see this is quite long. Here comes the cheat sheet:
strsplit(x,split) split x according to the substring split

Cheat Sheets for R

R can be quite cool when dealing with spatial data and geostatistics. So get yourself some support with these cheat sheets:

spatial cheat sheet

Etienne B. Racine (a gis and maps specialist) created this nice little cheat sheet with a special focus on raster datasets: filtering, sampling and editing. Supported by  infographics you will get an idea about the algorithms/functions behaviour and meaning:

Etienne’s cheat sheet for raster and spatial data

a whole library of sheets

As you might have seen on the link to Etienne’s cheat sheet it was published on a RStudio page. They also serve a distinct webpage for them. You can find sheets for data wranglers or visualisation enthusiasts:

R cheat sheet library provided by RStudio

managing data

The second sentence on this sheet summarize it all: “The best cheat sheets are those that you make yourself!” Nevertheless Andreas Hamann from the University of Alberta created this data management cheat sheet.  It’s quite long but gives you an idea about most stuff you need for everyday fun with R.

data.table lovers

If you love data.tables this cheat sheet is for you. It was made by the guys at datacamp. Not easy to read neither to print but quite useful to have it on your desktop:

datacamp data.table cheat shee

hail the regression

I have to confess that I love regression analysis. So does Vito Ricci as he created the regression cheat sheet for R. It lacks of minimal examples yet you can scan the sheet quite easy and get an idea about a function:

regression cheat sheet

R goes spatial

You might be interested in a handy overview for your work with geodata in R. Together with the GDAL bindings you can do a lot of stuff in R and even use the R syntax in some QGIS scripts. Nevertheless you need to know how to code. The University of Lancaster has a nicely written summary with all the packages you might already use or heard of:

R cheat sheet for spatial analysis

Sidenote: If you’re interested in spatial methods take a look on the page of Francisco Rodriguez-Sanchez: Spatial data in R: Using R as a GIS

the one I use

I am using R mostly for ETL tasks and need more basic commands and do some basic stuff within R. So I often use the “official” R cheat sheet / reference card which I printed out and folded nicely. It provides a short summary on each command and sometimes a small example. unfortunately its format is a bit strange…

R reference card

the one you use

What is your favourite cheat sheet? Have you created one for yourself and would like to share it here? Leave a comment!