Blog Archives

Benford’s Law after converting count data to be in base 5

March 8, 2012
By
Benford’s Law after converting count data to be in base 5

Firstly, I know nothing about election fraud – this isn’t a serious post. But, I do like to do some simple coding. Ben Goldacre posted on using Benford’s Law to look for evidence of Russian election fraud. Then Richie Cotton did the same, but using R. Commenters on both sites suggested that as the data

Read more »

Logistic regression – simulation for a power calculation…

November 18, 2010
By
Logistic regression – simulation for a power calculation…

Please note - I’ve spotted a problem with the approach taken in this post – it seems to underestimate power in certain circumstances. I’ll post again with a correction or a more full explanation when I’ve sorted it. So, I posted an answer on cross validation regarding logistic regression.   I thought I’d post it

Read more »

Science is vital – what we don’t know yet

October 6, 2010
By
Science is vital – what we don’t know yet

This post is not about R (for a change). For working UK scientists, science is vital – sign the on-line petition to preserve science funding. For my contribution of what we don’t know yet - We don’t know whether we can use biomarkers of kidney injury to personalise the doses of medications to maximise the

Read more »

How to check if a file exists with HTTP and R

September 1, 2010
By
How to check if a file exists with HTTP and R

So, there’s probably an easier way to do this (please let me know if you know it)… Suppose you’re working with a system which creates (binary) files and posts them for download on a website. You know the names of the files that will be created. However, they may not have been made yet (they’re

Read more »

An HSV colour wheel in R

August 9, 2010
By
An HSV colour wheel in R

If you’ve read any of my previous posts, you’ll notice that they’re rather scanty on colour. There’s a reason for this. Mainly, that to get a good colour output takes some time. I recently read a commentary in Nature methods (sorry if you don’t have access to it, but this looks like it may be

Read more »

Summary plots

August 2, 2010
By
Summary plots

So, when you first look at some data, it’s helpful to get a feel of it. One way to do this is to do a plot or two. I’ve found myself continuously doing the same series of plots for different datasets, so in the end I wrote this short code to put all the plots

Read more »

Visualizing 3d data – plotting quartiles separately

July 30, 2010
By
Visualizing 3d data – plotting quartiles separately

In this previous post, we’ve looked at displaying three dimensional data.  One major problem is when there is a high density of data, it can be difficult to see what’s going on in a 3 dimensional plot. One way of looking at the data in more detail is to break it up.  Take a look

Read more »

Turning your data into a 3d chart

July 23, 2010
By
Turning your data into a 3d chart

Some charts are to help you analyse data. Some charts are to wow people. 3d charts are often the latter, but occasionally the former. In this post, we’ll look at how to turn your data into a 3d chart. Let’s use the data from this previous post. Use the code which turns the .csv spreadsheet

Read more »

Quick scatterplot with associated histograms

July 22, 2010
By
Quick scatterplot with associated histograms

R can produce some beautiful graphics, and there are some excellent packages, such as lattice and ggplot2 to represent data in original ways.  But sometimes, all you want to do is explore the realtionship between pairs of variables with the minimum of fuss. In this post we’ll use the data which we imported in the

Read more »

Matrix scatterplot of the Airquality data using lattice

July 20, 2010
By
Matrix scatterplot of the Airquality data using lattice

In this post we will build on the last one, and create a matrix scatterplot. The package lattice allows for some really excellent graphics. In case you haven’t already seen it I recommend the R Graph Gallery for some examples of what it can do – browse the graphics by package used to create them.

Read more »