1. Using R run the mtcars examples from the end of the Lecture 14 presentation. Show the plots you have created in your homework document.
#install.packages("ggplot2")
require("ggplot2")
## Loading required package: ggplot2
mtcars$gear <- factor(mtcars$gear,levels=c(3,4,5),
labels=c("3gears","4gears","5gears"))
mtcars$am <- factor(mtcars$am,levels=c(0,1),
labels=c("Automatic","Manual"))
mtcars$cyl <- factor(mtcars$cyl,levels=c(4,6,8),
labels=c("4cyl","6cyl","8cyl"))
2. Complete and run the Tree Maps example from lecture 15.
qplot(mpg, data=mtcars, geom="density",
fill=gear, alpha=I(.5),
main="Distribution of Gas Milage", xlab="Miles Per Gallon",
ylab="Density")

qplot(wt, mpg, data=mtcars, geom=c("point", "smooth"), color=cyl,
main="Smoothers of MPG on Weight",
xlab="Weight", ylab="Miles per Gallon")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

qplot(gear, mpg, data=mtcars,
geom=c("boxplot", "jitter"),
fill=gear, main="Mileage by Gear Number",
xlab="", ylab="Miles per Gallon")

3. Reproduce some plots using Quandl with a data set other than unemployment or GDP.
#install.packages("Quandl")
library(Quandl)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
mydata <- Quandl("FRED/BA06RC1A027NBEA")
mydata
## Date Value
## 1 2017-01-01 7966.330
## 2 2016-01-01 7607.227
## 3 2015-01-01 7384.947
## 4 2014-01-01 7016.975
## 5 2013-01-01 6672.644
## 6 2012-01-01 6491.224
## 7 2011-01-01 6217.286
## 8 2010-01-01 5975.676
## 9 2009-01-01 5859.232
## 10 2008-01-01 6142.159
## 11 2007-01-01 6018.089
## 12 2006-01-01 5692.569
## 13 2005-01-01 5351.949
## 14 2004-01-01 5087.562
## 15 2003-01-01 4826.252
## 16 2002-01-01 4714.375
## 17 2001-01-01 4695.225
## 18 2000-01-01 4587.709
## 19 1999-01-01 4235.579
## 20 1998-01-01 3967.072
## 21 1997-01-01 3674.032
## 22 1996-01-01 3414.515
## 23 1995-01-01 3215.921
## 24 1994-01-01 3033.677
## 25 1993-01-01 2884.472
## 26 1992-01-01 2781.676
## 27 1991-01-01 2626.972
## 28 1990-01-01 2564.522
## 29 1989-01-01 2415.119
## 30 1988-01-01 2280.602
## 31 1987-01-01 2107.867
## 32 1986-01-01 1961.526
## 33 1985-01-01 1847.999
## 34 1984-01-01 1718.002
## 35 1983-01-01 1563.540
## 36 1982-01-01 1479.187
plot(mydata)

mydata <- Quandl("FRED/BA06RC1A027NBEA", type="ts")
mydata
## Time Series:
## Start = 1982
## End = 2017
## Frequency = 1
## [1] 1479.187 1563.540 1718.002 1847.999 1961.526 2107.867 2280.602
## [8] 2415.119 2564.522 2626.972 2781.676 2884.472 3033.677 3215.921
## [15] 3414.515 3674.032 3967.072 4235.579 4587.709 4695.225 4714.375
## [22] 4826.252 5087.562 5351.949 5692.569 6018.089 6142.159 5859.232
## [29] 5975.676 6217.286 6491.224 6672.644 7016.975 7384.947 7607.227
## [36] 7966.330
ts.plot(mydata)

data <- read.csv("http://datasets.flowingdata.com/post-data.txt")
#install.packages("portfolio")
library(portfolio)
## Loading required package: grid
## Loading required package: lattice
## Loading required package: nlme
map.market(id=data$id, area=data$views, group=data$category,
color=data$comments, main="FlowingData Map")
