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.
The data for this assignment are available from the course web site as a single zip file:
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.
fips: A five-digit number (represented as a string) indicating the U.S. countySCC: The name of the source as indicated by a digit string (see source code classification table)Pollutant: A string indicating the pollutantEmissions: Amount of PM2.5 emitted, in tonstype: The type of source (point, non-point, on-road, or non-road)year: The year of emissions recordedSource 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”.
You can read each of the two files using the readRDS() function in R.
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.
# Load the NEI and SCC data frames from the .rds files
NEI <- readRDS("summarySCC_PM25.rds")
SCC <- readRDS("Source_Classification_Code.rds")
We first aggregate the total PM2.5 emission from all sources for each year: 1999, 2002, 2005, & 2008.
aggTotals <- aggregate(Emissions ~ year,NEI, sum)
Next, we plot the total PM2.5 Emission from all sources:
barplot(
(aggTotals$Emissions)/10^6,
names.arg=aggTotals$year,
xlab="Year",
ylab="PM2.5 Emissions (1,000,000 Tons)",
main="Total PM2.5 Emissions From All US Sources"
)
From the plot, we observe that total emissions have decreased in the US from 1999 to 2008.
Here, we first aggregate total emissions from PM2.5 for Baltimore City, Maryland, for years 1999 to 2008.
baltimoreNEI <- NEI[NEI$fips=="24510",]
aggTotalsBaltimore <- aggregate(Emissions ~ year, baltimoreNEI,sum)
Next, we make a plot for this data:
barplot(
aggTotalsBaltimore$Emissions,
names.arg=aggTotalsBaltimore$year,
xlab="Year",
ylab="PM2.5 Emissions (Tons)",
main="Total PM2.5 Emissions - All Baltimore City Sources"
)
Thus, we find that overall total emissions from PM2.5 have decreased in Baltimore City, Maryland, from 1999 to 2008.
To answer question 3, we obtain the following plot:
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.3.3
q3 <- ggplot(baltimoreNEI,aes(factor(year),Emissions,fill=type)) +
geom_bar(stat="identity") + guides(fill=FALSE)+
facet_grid(.~type,scales = "free",space="free") +
labs(x="year", y=expression("Total PM"[2.5]*" Emission (Tons)")) +
labs(title=expression("PM"[2.5]*" Emissions in Baltimore City 1999-2008 by Source Type"))
print(q3)
Here, non-road, nonpoint, on-road source types have decreased emissions overall from 1999-2008 in Baltimore City.
Furthermore, the point source saw a marginal increase overall from 1999-2008. In particular, the point source saw a significant increase up till 2005, from which it began decreasing again from 2008.
We begin this question by subsetting coal combustion source factors in NEI data:
combustionRelated <- grepl("comb", SCC$SCC.Level.One, ignore.case=TRUE)
coalRelated <- grepl("coal", SCC$SCC.Level.Four, ignore.case=TRUE)
coalCombustion <- (combustionRelated & coalRelated)
combustionSCC <- SCC[coalCombustion,]$SCC
combustionNEI <- NEI[NEI$SCC %in% combustionSCC,]
To answer question 4, we obtain the following plot:
library(ggplot2)
q4 <- ggplot(combustionNEI,aes(factor(year),Emissions/10^5)) +
geom_bar(stat="identity",fill="grey",width=0.75) +
theme_bw() + guides(fill=FALSE) +
labs(x="year", y=expression("Total PM"[2.5]*" Emission (1000000 Tons)")) +
labs(title=expression("PM"[2.5]*" Coal Combustion Source Emissions Across US from 1999-2008"))
print(q4)
From the plot, we find that emissions from coal combustion related sources have decreased from 6,000,000 to under 4,000,000 from 1999-2008.
Similarly, we begin this question by subsetting the motor vehicles data:
vehicles <- grepl("vehicle", SCC$SCC.Level.Two, ignore.case=TRUE)
vehiclesSCC <- SCC[vehicles,]$SCC
vehiclesNEI <- NEI[NEI$SCC %in% vehiclesSCC,]
We do the same for motor vehicles in Baltimore:
baltimoreVehiclesNEI <- vehiclesNEI[vehiclesNEI$fips==24510,]
To answer question 5, we obtain the following plot:
library(ggplot2)
q5 <- ggplot(baltimoreVehiclesNEI,aes(factor(year),Emissions)) +
geom_bar(stat="identity",fill="grey",width=0.75) +
theme_bw() + guides(fill=FALSE) +
labs(x="year", y=expression("Total PM"[2.5]*" Emission (10^6 Tons)")) +
labs(title=expression("PM"[2.5]*" Motor Vehicle Source Emissions in Baltimore from 1999-2008"))
print(q5)
From the plot, we observe that emissions from motor vehicle sources have decreased from 1999-2008 in Baltimore City.
Next, we compare emissions from motor vehicle sources in Baltimore City (fips == “24510”) with emissions from motor vehicle sources in Los Angeles County, California (fips == “06037”):
vehiclesBaltimoreNEI <- vehiclesNEI[vehiclesNEI$fips == 24510,]
vehiclesBaltimoreNEI$city <- "Baltimore City"
vehiclesLANEI <- vehiclesNEI[vehiclesNEI$fips=="06037",]
vehiclesLANEI$city <- "Los Angeles"
bothNEI <- rbind(vehiclesBaltimoreNEI,vehiclesLANEI)
Finally, we obtain the plot:
library(ggplot2)
q6 <- ggplot(bothNEI, aes(x=factor(year), y=Emissions, fill=city)) +
geom_bar(aes(fill=year),stat="identity") +
facet_grid(scales="free", space="free", .~city) +
guides(fill=FALSE) +
labs(x="year", y=expression("Total PM"[2.5]*" Emission (Kilo-Tons)")) +
labs(title=expression("PM"[2.5]*" Motor Vehicle Source Emissions in Baltimore & LA, 1999-2008"))
print(q6)
Hence, we observe that Los Angeles has seen the greatest changes over time in motor vehicle emissions.