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).
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 I will use for analysis are for 1999, 2002, 2005, and 2008.
First read the rds file unzipped from NEI.
setwd("~/Desktop/US PM2.5 Emissions data/")
NEI <- readRDS("summarySCC_PM25.rds")
SCC <- readRDS("Source_Classification_Code.rds")
Aggregate emissions by year, and plot bar graph of total emissions of each year.
agg <- aggregate(Emissions ~ year,NEI, sum)
barplot((agg$Emissions)/10^6,names.arg=agg$year,xlab = "Year",ylab = "PM2.5(in 10^6 Tons)",main = "Total PM2.5 Emission from all sources")
From the barplot we can see that the total PM2.5 emissions decreased in the United States from 1999 to 2008. About 2 million tons of emission was reduced in 1999-2002 and 2005-2008.However, 2002-2005 has not seen decrease as great as the other two three years.
Since fips indicates the U.S county, we can subset NEI data by Baltimore fips.
bal <- subset(NEI,fips == "24510")
By aggregating total emissions by year in Baltimore, we can get a barplot showing the change of total emissions across years.
aggb <- aggregate(Emissions~year,bal,sum)
barplot((aggb$Emissions)/10^3,names.arg = aggb$year,xlab = "Year",ylab = "PM2.5(in 10^3 Tons)",main = "Total PM2.5 Emission from all sources in Baltimore City")
Using ggplot2 to plot how emission changes over years in different sources
library(ggplot2)
g <- ggplot(data = bal,aes(factor(year),Emissions,fill = type))
typ <- g+geom_bar(stat = "identity")+theme_bw()+facet_grid(.~type)+guides(fill = F)+labs(x="year", y=expression("Total PM"[2.5]*" Emission (Tons)")) + labs(title=expression("PM"[2.5]*" Emissions, Baltimore City 1999-2008 by Source Type"))
print(typ)
As you can see, the barplot shows how emissions from four sources change in different time periods. Nonpoint, Onroad, Nonroad have seen decrease in PM2.5 emissions across the 9 years. Only emissions of point source increased from 1999 to 2005, and decreased sharply from 2005 to 2008.
Subset vehicle emissions data in Baltimore and plot by ggplot2.
bal <- subset(NEI,fips == "24510")
vehi <- grepl("vehicle",SCC$SCC.Level.Two,ignore.case = T)
vehiSCC <- SCC[vehi,]$SCC
vehibal <- bal[bal$SCC %in% vehiSCC,]
ggm <- ggplot(vehibal,aes(factor(year),Emissions))+geom_bar(stat = "identity",fill = "grey",width = 0.7)+ theme_bw() + guides(fill=FALSE) + labs(x="year", y=expression("Total PM"[2.5]*" Emission")) + labs(title=expression("PM"[2.5]*" Motor Vehicle Source Emissions in Baltimore from 1999-2008"))
print(ggm)
We can see from the graph that the emissions from motor vehicle sources vastly decreases from 1999-2008.
Subset vehicle emissions in Baltimore & Los Angeles.
twcity <- subset(NEI,fips == "24510"|fips =="06037")
vehi <- grepl("vehicle",SCC$SCC.Level.Two,ignore.case = T)
vehiSCC <- SCC[vehi,]$SCC
vehitw <- twcity[twcity$SCC %in% vehiSCC,]
Set the value of fips variable as city names
vehitw$fips[vehitw$fips == "06037"] <- "Los Angeles County"
vehitw$fips[vehitw$fips == "24510"] <- "Baltimore City"
Plot the motor vehicle sources in Baltimore City and Los Angeles City.
ggtwo <- ggplot(vehitw,aes(factor(year),Emissions,fill = year))+geom_bar(stat = "identity")+ facet_grid(.~fips) + theme_bw() + guides(fill=FALSE) + labs(x="year", y=expression("Total PM"[2.5]*" Emission")) + labs(title=expression("PM"[2.5]*" Motor Vehicle Source Emissions in Baltimore & LA from 1999-2008"))
print(ggtwo)
It’s not a surprise at all that the emissions from LA City largely exceed the emission from Baltimore City in 1999-2008 as a whole. Different from Baltimore City, LA City has seen increase of motor vehicle emissions from 1999-2005, but decreases in 2005-2008.