-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot1.R
More file actions
24 lines (19 loc) · 741 Bytes
/
Copy pathplot1.R
File metadata and controls
24 lines (19 loc) · 741 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
# 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)
sum_year <- with(NEI, tapply(Emissions, year, sum))
totalpm25 <- data.frame(year = names(sum_year), pm25 = sum_year)
png(filename = "plot1.png")
with(totalpm25,
barplot(height = pm25, names.arg = year,
xlab = "YEAR",
ylab = expression("Total PM"[2.5]*" emission"),
col = year))
dev.off()