## Quick start with R: Improving our regression model (Part 29)

Last time we created two variables and used the lm() command to perform a least squares regression on them, and diagnosing our regression using the plot() command. Here are the data again. height = c(176, 154, 138, 196, 132, 176, 181, 169, 150, 175) bodymass = c(82, 49, 53, 112, 47, 69, 77, 71, 62, …

## Quick start with R: Diagnosing our regression model (Part 28)

Last time we created two variables and used the lm() command to perform a least squares regression on them, treating one of them as the dependent variable and the other as the independent variable. Here they are again. height = c(176, 154, 138, 196, 132, 176, 181, 169, 150, 175) bodymass = c(82, 49, 53, …

## Quick start with R: More on regression (Part 27)

In my last blog we created two variables and used the lm() command to perform a least squares regression on them, treating one of them as the dependent variable and the other as the independent variable. Here they are again. height = c(176, 154, 138, 196, 132, 176, 181, 169, 150, 175) bodymass = c(82, …

## Quick start with R: Scatterplot with regression line (Part 26)

Today let’s re-create two variables and see how to plot them and include a regression line. We take height to be a variable that describes the heights (in cm) of ten people. Copy and paste the following code to the R command line to create this variable. height

## Quick start with R: Symbol colours and legend in qplot (Part 25)

In Blog 24 we saw how to use qplot to map symbol size to a categorical variable. Now we see how to control symbol colours and create legend titles. Copy in the same dataset of Blog 24 (a medical data set relating to patients in a randomised controlled trial: M

## Quick start with R: Symbol sizes in qplot (Part 24)

In Blog 24, let’s see how to use qplot to map symbol colour to a categorical variable. Copy in the following dataset (a medical dataset relating to patients in a randomised controlled trial): M

## Quick start with R: Using qplot() function (Part 23)

In Part 23, let’s see how to use qplot to create a simple scatterplot. The qplot (quick plot) system is a subset of the ggplot2 (grammar of graphics) package which you can use to create nice graphs. It is great for creating graphs of categorical data, because you can map symbol colour, size and shape …

## Quick start with R: Mathematical expressions for graphs (Part 22)

In Blog 22, let’s see how to create mathematical expressions for your graph. Mathematical expressions on graphs are made possible through expression(paste()) and substitute(). If you need mathematical expressions as axis labels, switch off the default axes and include Greek symbols by writing them out in English. You can create fractions through the frac() command. …

## Quick start with R: Plotting multiple graphs on the same page (Part 21)

Today we see how to set up multiple graphs on the same page. We use the syntax par(mfrow=(A,B)), where A refers to the number of rows and B to the number of columns (and where each cell will hold a single graph). This syntax sets up a plotting environment of A rows and B columns. …

## Quick start with R: Recoding (Part 20)

You can re-code an entire vector or array at once. To illustrate, let’s set up a vector that has missing values. A