Scatterplots

We will use a dataset containing data on 1993 auto models, most of it collected by Consumers Union, and made available over the internet on the Statlib archive; paste in the source code at this link to load the data we will be using into your R session. The data frame is called "Cars93", use the attach command to allow you to access the columns by name.

Here are some examples of the basic plot features that will be useful for looking at relationships between variables.



Example

You can download CO2 data from Scripps:
Mauna Loa CO2 data
Historical CO2 inferred from Ice Core data
  IceCoreCO2 <- read.csv("~/Desktop/merged_ice_core_yearly.csv",
		header=FALSE,skip=28)
head(IceCoreCO2)
names(IceCoreCO2) <- c("Year","CO2")
attach(IceCoreCO2)
plot(Year,CO2,pch=19,col="red",col.lab="green",col.axis="purple")
?loess
CO2.lo <- loess(CO2~Year,data=IceCoreCO2)
lines(CO2.lo,col="blue",lwd=2)
title("Atmospheric CO2, ppm",col.main="magenta")
  

Exercises



Exercise

Load the Brain/Body size dataset
  Brains <- read.table("http://people.reed.edu/~jones/141/Brains.dat",
	                header=TRUE,as.is=TRUE)
Make a scatterplot of log(Brain.WT) on log(Body.WT), using different plot symbols for the different classes of animal. Add a legend and title.


Math 141 Index

Albyn Jones