-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot5.R
More file actions
33 lines (27 loc) · 1.05 KB
/
plot5.R
File metadata and controls
33 lines (27 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Author: Kristijana A.
# Exploratory Data Analysis Week 4 Project
# Plot 5
library(lubridate)
library(dplyr)
setwd("ex-data-analysis-project")
data_url = "https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2FNEI_data.zip"
download.file(data_url, "pminfo.zip", method="curl")
unzip("pminfo.zip")
# Read files
NEI <- readRDS("summarySCC_PM25.rds")
SCC <- readRDS("Source_Classification_Code.rds")
# subset NEI to get Balitmore data
baltimore <- subset(NEI, fips == "24510")
# subset SCC to get vehicle related data
vehicle_collection <- condition <- grepl("vehicle", SCC[, "SCC.Level.Two"], ignore.case=TRUE)
# subset baltimore to get vehicle related data
vehicle_scc <- SCC[vehicle_collection,]
vehicle_scc_list <- vehicle_scc$SCC
vehicle_nei <- subset(baltimore, SCC %in% vehicle_scc_list)
# Start png
png(filename="plot5.png")
ggplot(vehicle_nei,aes(factor(year),Emissions)) +
geom_bar(stat="identity") +
labs(x="year", y="Total PM2.5 Emissions in Tons") +
labs(title="PM2.5 Motor Vehicle Emissions in Baltimore from 1999-2008")
dev.off()