Name:
Andrew ID:
Collaborated with:

This lab is to be done in class (completed outside of class if need be). You can collaborate with your classmates, but you must identify their names above, and you must submit your own lab as an knitted HTML file on Canvas, by Thursday 10pm, this week.

Important note: this assignment is to be completed using base R graphics. That means, e.g., no ggplot commands are allowed!

This week’s agenda: getting familiar with basic plotting tools; understanding the way layers work; recalling basic text manipulations; producing histograms and overlaid histograms.

Plot basics

n = 50
set.seed(0)
x = runif(n, min=-2, max=2)
y = x^3 + rnorm(n)
plot(x, y, type="p")

plot(x, y, type="l")

Adding to plots

x2 = sort(runif(n, min=-2, max=2))
y2 = x^2 + rnorm(n)

Fastest 100m sprint times

Below, we read in a data set of the 2988 fastest times recorded for the 100m sprint, in men’s track. (Usain Bolt may be slowing down now … but he was truly one of a kind!) We also read in a data set of the 2137 fastest times recorded for the 100m, in women’s track. Both of these data sets were scraped from http://www.alltime-athletics.com/m_100ok.htm (this website was apparently last updated in November 2017).

sprint.dat = read.table(
  file="http://www.stat.cmu.edu/~ryantibs/statcomp-S18/data/sprint.dat", 
  sep="\t", quote="", header=TRUE)
sprint.w.dat = read.table(
  file="http://www.stat.cmu.edu/~ryantibs/statcomp-S18/data/sprint.w.dat", 
  sep="\t", quote="", header=TRUE)

Text manipulations, and layered plots

More text manipulations, and histograms