-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot3.R
More file actions
23 lines (18 loc) · 763 Bytes
/
Copy pathplot3.R
File metadata and controls
23 lines (18 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# url to file
url <- "https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2FNEI_data.zip"
if (!file.exists("data.zip")) {
download.file(url = url, destfile = "data.zip", method = "curl")
}
# read the files inside .zip
unzip("data.zip", list = TRUE)
NEI <- readRDS(unzip("data.zip", "summarySCC_PM25.rds"))
SCC <- readRDS(unzip("data.zip", "Source_Classification_Code.rds"))
names(NEI)
library(dplyr)
library(ggplot2)
baltimore <- NEI %>% filter(fips == "24510") %>% group_by(year, type) %>% summarise(Emissions = sum(Emissions))
png(filename = "plot3.png")
ggplot(data = baltimore, aes(x = year, y = Emissions, group = type, col = type)) +
geom_line() +
ggtitle(label = expression("Total PM"[2.5]*" emissions by type"))
dev.off()