-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot1.r.R
22 lines (15 loc) · 838 Bytes
/
plot1.r.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Exploratory Data Analysis -
# Q.1. Have total emissions from PM2.5 decreased in the United States from 1999 to 2008? Using the base plotting system, make a plot showing the total PM2.5 emission from all sources for each of the years 1999, 2002, 2005, and 2008.
# upload data files
NEI <- readRDS("~/summarySCC_PM25.rds")
View(NEI)
SCC <- readRDS("~/Source_Classification_Code.rds")
View(SCC)
NEI_sampling <- NEI[sample(nrow(NEI), size=2000, replace=F), ]
Emissions <- aggregate(NEI[, 'Emissions'], by=list(NEI$year), FUN=sum)
Emissions$PM <- round(Emissions[,2]/1000,2)
png(filename='~/Course Project 2/plot1.png')
barplot(Emissions$PM, names.arg=Emissions$Group.1,
main=expression('Total Emission of PM'[2.5]),
xlab='Year', ylab=expression(paste('PM', ''[2.5], ' in Kilotons')))
dev.off()