January 2014 archive

Organism of the week #19 – Bird-brained humans

Most people who want to attract birds to their gardens put out bird-seed, or – if they’re really adventurous – mealworms. However, on the East London dockside where I lived until recently, one of the residents strewed the quayside with livers in December last year. Was this was a deliberate ploy to attract carrion crows for bird-on-variety-meat …

Descriptive statistics

Statistics can be used to describe a data set, or they can be used to infer how well a model fits a data set. In this post, we’ll look the the former kind of statistics, and how to extract them from R. The remaining posts in this series will mostly deal with statistical tests and …

Organism of the week #18 – Feeling rotten

It’s been ages since I did one of these, and today’s will not be terribly long or exciting, for the reason that is the very title of this post. Whilst bumbling around in the fridge looking for something bland and bowel-friendly, I chanced upon a lemon that had fallen into a oubliette in the bottom …

Plotting data

You can plot data using plot(). This can be used in several ways. The simplest is to plot some numeric x-values against some numeric y-values using: plot( x.variable.vector, y.variable.vector ) For example: x<-c( 1:10 ) y<-1 + 2*x plot( x, y ) However, for data you have imported into a data frame, the x and …

Formatting data

Although you will occasionally type data directly into R, more often than not, you will have a spread-sheet containing data which you want to import. R can easily import data from a comma-separated variable (CSV) file. If you open a CSV file using a text-editor, you will see that they look something like this inside …

Kinds of data

The sort of data you want to analyse in R may come in many forms. You will often be trying to model the interaction of some independent variables (a.k.a. input, predictor or explanatory variables, the things you’d plot on an x axis) to explain the values of some dependent variable (a.k.a. output, outcome or response variable, …

Running R code

The R interpreter is controlled by typing in plain-text commands at its command-line prompt >|. R commands are just text, so you can prepare a chunk of them in a text-editor, and then copy-and-paste them directly into R to run them immediately. Try copying and pasting the line below at the prompt: print(“Hello world”) Lo …