-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.R
More file actions
33 lines (25 loc) · 838 Bytes
/
plot2.R
File metadata and controls
33 lines (25 loc) · 838 Bytes
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 2
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")
# sum emissions column by year
totalPM <- baltimore %>%
group_by(year) %>%
summarise(Emissions = sum(Emissions))
# start PNG file
png(filename = "plot2.png")
# plot
barplot(totalPM$Emissions, names=totalPM$year, xlab="Year",
ylab="Total PM2.5 Emissions",
main="Total PM2.5 Emissions in Baltimore by Year")
dev.off()