Fine particulate matter (PM2.5) is an ambient air pollutant for which there is strong evidence that it is harmful to human health. In the United States, the Environmental Protection Agency (EPA) is tasked with setting national ambient air quality standards for fine PM and for tracking the emissions of this pollutant into the atmosphere. Approximatly every 3 years, the EPA releases its database on emissions of PM2.5. This database is known as the National Emissions Inventory (NEI). You can read more information about the NEI at the EPA National Emissions Inventory web site.
For each year and for each type of PM source, the NEI records how many tons of PM2.5 were emitted from that source over the course of the entire year. The data that you will use for this assignment are for 1999, 2002, 2005, and 2008. Data
The zip file contains two files:
PM2.5 Emissions Data (summarySCC_PM25.rds): This file contains a data frame with all of the PM2.5 emissions data for 1999, 2002, 2005, and 2008. For each year, the table contains number of tons of PM2.5 emitted from a specific type of source for the entire year. Here are the first few rows.
Source Classification Code Table (Source_Classification_Code.rds): This table provides a mapping from the SCC digit strings int he Emissions table to the actual name of the PM2.5 source. The sources are categorized in a few different ways from more general to more specific and you may choose to explore whatever categories you think are most useful. For example, source “10100101” is known as “Ext Comb /Electric Gen /Anthracite Coal /Pulverized Coal”.
The overall goal of this assignment is to explore the National Emissions Inventory database and see what it say about fine particulate matter pollution in the United states over the 10-year period 1999-2008. You may use any R package you want to support your analysis.
library(ggplot2)
library(dplyr)
SCC <- readRDS(file = "Source_Classification_Code.rds")
NEI <- readRDS(file = "summarySCC_PM25.rds")
national<- merge(NEI,SCC, by="SCC")
national$year<- as.factor(national$year)
national_a<- tapply(national$Emissions, national$year, sum)
national_a<- barplot(national_a,
main=" Fine Particulate Emissions \n Total United States\n",
xlab="Years",ylab=" Amount of PM2.5 emitted, in tons")
plot1 <- national_a
print(plot1)
## [,1]
## [1,] 0.7
## [2,] 1.9
## [3,] 3.1
## [4,] 4.3
baltimore<- filter(national, fips == "24510" )
a<- tapply(baltimore$Emissions, baltimore$year, sum)
plot2<- barplot(a, main="Fine Particulate Emissions \n Baltimore City, Maryland\n",
xlab="Years", ylab="Amount of PM2.5 emitted, in tons")
print(plot2)
## [,1]
## [1,] 0.7
## [2,] 1.9
## [3,] 3.1
## [4,] 4.3
baltimore<- filter(national, fips == "24510" )
g<- ggplot(baltimore, aes(year, Emissions))+
labs(title="Fine Particulate Emissions \n Baltimore City, Maryland \n")+
xlab("") + ylab("Amount of PM2.5 emitted, in tons")+scale_size_identity(0.1)
plot3<- g + geom_bar(stat="identity", fill="blue") +facet_grid(.~type)
print(plot3)
baltimore<- filter(national, fips == "24510" )
vehicles_on<- filter(baltimore, type == "ON-ROAD" )
vehicles_non <- filter(baltimore, type == "NON-ROAD" )
vehicles<- rbind(vehicles_on, vehicles_non)
g<- ggplot(vehicles, aes(year, Emissions))+
labs(title = " Fine Particulate Emissions\n Motor Vehicle Sources \n Baltimore City\n")+
xlab( "Years") + ylab("Amount of PM2.5 emitted, in tons")
plot5<- g + geom_bar(stat="identity", fill="brown")
print(plot5)
road<- filter(national, fips == "24510" | fips == "06037")
vehicles_one<- filter(road, type == "ON-ROAD")
vehicles_none <- filter(road, type == "NON-ROAD")
vehicles<- rbind(vehicles_one,vehicles_none)
vehicles$fips<- gsub("24510", "Baltimore" ,vehicles$fips)
vehicles$fips<- gsub("06037", "Los Angeles", vehicles$fips)
g<- ggplot(vehicles, aes(year, Emissions))+labs(title = "Comparison Vehicles Emissions")+
ylab("Amount of emissions")
plot6<- g + geom_bar(stat="identity", fill ="brown") + facet_grid(.~fips)
print(plot6)
dev.copy(png, file="./plot6.png", width=480, height=480)
## png
## 3
dev.off()
## png
## 2
This activity has a purely didactic proposal as part of the Data Science Course