Annual average PM2.5 averaged over the period 2008 through 2010
pollution <- read.csv("data/avgpm25.csv", colClasses = c("numeric", "character", "factor", "numeric", "numeric"))
head(pollution)
## pm25 fips region longitude latitude
## 1 9.771 01003 east -87.75 30.59
## 2 9.994 01027 east -85.84 33.27
## 3 10.689 01033 east -87.73 34.73
## 4 11.337 01049 east -85.80 34.46
## 5 12.120 01055 east -86.03 34.02
## 6 10.828 01069 east -85.35 31.19
Do any counties exceed the standard of 12 μg/m3 ?
One dimension + Five-number summary + Boxplots + Histograms + Density plot + Barplot
summary(pollution$pm25)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.38 8.55 10.00 9.84 11.40 18.40
boxplot(pollution$pm25,col="blue")
boxplot(pollution$pm25)
abline(h=12,col="blue")
barplot(table(pollution$region), col = "wheat", main = "Number of Counties in Each Region")
boxplot(pm25 ~ region, data = pollution, col = c("magenta","green"))
par(mfrow = c(2, 1), mar = c(4, 4, 2, 1))
hist(subset(pollution, region == "east")$pm25, col = "magenta")
hist(subset(pollution, region == "west")$pm25, col = "green")
with(pollution, plot(latitude, pm25))
abline(h=12,lwd=2,lty=2)
with(pollution, plot(latitude, pm25,col=region))
abline(h=12,lwd=2,lty=2)
par(mfrow = c(1, 2), mar = c(5, 4, 2, 1))
with(subset(pollution, region == "west"), plot(latitude, pm25, main = "West",col=region))
with(subset(pollution, region == "east"), plot(latitude, pm25, main = "East",col=region))