Publications by mrtnj

Slides from my R intro seminar

23.04.2013

Here are my slides from a short introductory seminar on R (essentially going through part I of the R tutorial) last week. As magic lantern pictures go, they’re hideously ugly, but they were mostly there for future reference. Most of the seminar was spent showing RStudio. This Friday, we’ll practice some uses of qplot and make some linear mod...

952 sym 14 img

Slides and exercise from my second R intro seminar

28.04.2013

This week I held the second introductory seminar on R, and I think it went pretty well — though I guess you really should ask my colleagues if you want to know. The first seminar was a lecture, and this seminar was a tutorial where we made some plots and calculated a few of the usual statistics. Of course the only real way to learn R is to play...

1683 sym 14 img

”How to draw the line” with ggplot2

30.05.2013

In a recent tutorial in the eLife journal, Huang, Rattner, Liu & Nathans suggested that researchers who draw scatterplots should start providing not one but three regression lines. I quote, Plotting both regression lines gives a fuller picture of the data, and comparing their slopes provides a simple graphical assessment of the correlation coeffi...

3187 sym R (1172 sym/11 pcs) 24 img

Using R: drawing several regression lines with ggplot2

02.06.2013

Occasionally I find myself wanting to draw several regression lines on the same plot, and of course ggplot2 has convenient facilities for this. As usual, don’t expect anything profound from this post, just a quick tip! There are several reasons we might end up with a table of  regression coefficients connecting two variables in different ways....

1871 sym R (616 sym/3 pcs) 16 img

Using R: Two plots of principal component analysis

26.06.2013

PCA is a very common method for exploration and reduction of high-dimensional data. It works by making linear combinations of the variables that are orthogonal, and is thus a way to change basis to better see patterns in data. You either do spectral decomposition of the correlation matrix or singular value decomposition of the data matrix and get...

2855 sym R (1296 sym/4 pcs) 20 img

R intro seminars, take 2: some slides about data frames, linear models and statistical graphics

07.11.2013

I am doing a second installment of the lunch seminars about data analysis with R for the members of the Wright lab. It’s pretty much the same material as before — data frames, linear models and some plots with ggplot2 — but I’ve sprinkled in some more exercises during the seminars. I’ve tried emphasising scripting a bit more than last ...

1200 sym 14 img

A slightly different introduction to R, part V: plotting and simulating linear models

11.11.2013

In the last episode (which was quite some time ago) we looked into comparisons of means with linear models. This time, let’s visualise some linear models with ggplot2, and practice another useful R skill, namely how to simulate data from known models. While doing this, we’ll learn some more about the layered structure of a ggplot2 plot, and s...

7973 sym R (2432 sym/18 pcs) 20 img

Using R: Coloured sizeplot with ggplot2

17.11.2013

Someone asked about this and I though the solution with ggplot2 was pretty neat. Imagine that you have a scatterplot with some points in the exact same coordinates, and to reduce overplotting you want to have the size of the dot indicating the number of data points that fall on it. At the same time you want to colour the points according to some ...

2076 sym R (637 sym/2 pcs) 18 img

Fall is the data analysis season

07.12.2013

Dear diary, I spent a lot of my summer in the lab, and my fall has been mostly data analysis, with a little writing and a couple of courses thrown in there. Data analysis means writing code, and nowadays I do most of my work with the help of R. R has even replaced python and perl for most ad hoc scripting. Case in point: I recently wrote an R scr...

2889 sym 16 img

Books and lessons about ggplot2

19.02.2014

I recently got an email from a person at Packt publishing, who suggested I write a book for them about ggplot2. My answer, which is perfectly true, is that I don’t have the time, nor the expertise to do that. What I didn’t say is that 1) a quick web search suggests that Packt doesn’t have the best reputation and 2) there are already two boo...

3961 sym 14 img