Articles by mrtnj

Using R: barplot with ggplot2

March 19, 2014 | mrtnj

Ah, the barplot. Loved by some, hated by some, the first graph you’re likely to make in your favourite office spreadsheet software, but a rather tricky one to pull off in R. Or, that depends. If you just need a barplot that displays the value of each data point ... [Read more...]

Morning coffee: scripting language

March 13, 2014 | mrtnj

Several people have asked: what scripting language should biologists learn if they are interested in doing a little larger-scale data analysis and have never programmed before? I’m not an expert, but these are the kinds of things I tend to say: The language is not so important; the same ... [Read more...]

Using R: common errors in table import

March 6, 2014 | mrtnj

I’ve written before about importing tabular text files into R, and here comes some more. This is because I believe (firmly) that importing data is the major challenge for beginners who want to analyse their data in R. What is the most important thing about using any statistics software? ... [Read more...]

Using R: correlation heatmap, take 2

March 3, 2014 | mrtnj

Apparently, this turned out to be my most popular post ever.  Of course there are lots of things to say about the heatmap (or quilt, tile, guilt plot etc), but what I wrote was literally just a quick celebratory post to commemorate that I’d finally grasped how to combine ... [Read more...]

Books and lessons about ggplot2

February 19, 2014 | mrtnj

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 ... [Read more...]

Fall is the data analysis season

December 7, 2013 | mrtnj

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. ... [Read more...]

Using R: Coloured sizeplot with ggplot2

November 17, 2013 | mrtnj

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 ... [Read more...]

Using R: Two plots of principal component analysis

June 26, 2013 | mrtnj

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 ... [Read more...]

Using R: drawing several regression lines with ggplot2

June 2, 2013 | mrtnj

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 ... [Read more...]

”How to draw the line” with ggplot2

May 30, 2013 | mrtnj

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 ... [Read more...]

Slides and exercise from my second R intro seminar

April 28, 2013 | mrtnj

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 ... [Read more...]

Slides from my R intro seminar

April 23, 2013 | mrtnj

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’... [Read more...]

Using R: reading tables that need a little cleaning

March 24, 2013 | mrtnj

Sometimes one needs to read tables that are a bit messy, so that read.table doesn’t immediately recognize the content as numerical. Maybe some weird characters are sprinkled in the table (ever been given a table with significance stars in otherwise numerical columns?). Some search and replace is needed. ... [Read more...]

Using R: Correlation heatmap with ggplot2

March 21, 2013 | mrtnj

Just a short post to celebrate that I learned today how incredibly easy it is to make a heatmap of correlations with ggplot2 (and reshape2, of course). So, what is going on in that short passage? cor makes a correlation matrix with all the pairwise correlations between variables (twice; plus ... [Read more...]

A slightly different introduction to R, part IV

February 21, 2013 | mrtnj

Now, after reading in data, making plots and organising commands with scripts and Sweave, we’re ready to do some numerical data analysis. If you’re following this introduction, you’ve probably been waiting for this moment, but I really think it’s a good idea to start with graphics ... [Read more...]

More Haskell: a bootstrap

February 16, 2013 | mrtnj

So my playing around with Haskell goes on. You can follow the progress of the little bootstrap exercise on github. Now it’s gotten to the point where it actually does a bootstrap interval for the mean of a sample. Consider the following R script: [1] 10.31 2.5% 97.5% 9.72475 10.85200 So, that was a simple […] [Read more...]
1 2 3 4

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)