Comparison of means: the t test
A t test is used to compare the means of two data sets, and it relies on calculation of a test statistic called t. This statistic is derived from the two data sets and it is defined as the difference between the means of the two data sets, x̅1 and x̅2 (or the difference between a mean x̅ and a reference value, xref) divided by the pooled standard error of the mean(s).
Comparison of variances: the F test
An F test is used to compare the variances of two data sets:
- As it is used to compare variances, the dependent data must - by definition - be numeric.
- As it is used to compare two distinct sets of data, these sets represent the two levels of a factor.
The test statistic we use to compare the variances of the two data sets is called F, and it is defined very simply: F is the larger of the two variances divided by the smaller.
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 action? I don’t know, but whether or not this was the intention, it was certainly the result.
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 modelling.
Descriptive statistics should usually give a measure of the central tendency of a data set (the mean and/or median), and of the variability of the data set (the range, quartiles, variance and/or standard deviation).
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 of the salad drawer. Perhaps it’s just the sickness talking, but I found it rather beautiful:
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 y variables are now named columns in a data frame, rather than separate vectors. To plot data in data frames, there are two options. The first is to use the dollar $ syntax to access the vector of data within the data frame (here sycamore_seeds.csv) by its column name:
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 (this is dose_response.csv):
C,mu
0.125,0.69
0.25,0.68
0.5,0.687
1,0.63
2,0.467
4,0.252
8,0.091
16,0.021The first row contains labels for the columns, and the remaining rows contain the data. The pair of labels, and the pairs of data, are each separated by a comma.
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, the thing you’d put on a y axis).
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 and behold, R will spit out what you knew it would:
Teardrops of the swan
Last year, the most marvellous thing we saw in the pond-water microscopy practical was a ciliate, and this year the prize goes to that same clade. Ciliates don’t disappoint.
This is Lacrymaria olor, the “teardrop of the swan”. It’s a predator, like the Vorticella from last year, but rather than sitting rooted to the spot, Lacrymaria is an actively swimming hunter, with an enormously extendable proboscis that it uses to capture prey:

![Basic scatterplot [CC-BY-SA-3.0 Steve Cook]](/wp-content/uploads/2014/01/basic_scatterplot-300x294.png)