-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEDA_Plot4.R
More file actions
28 lines (20 loc) · 1.07 KB
/
Copy pathEDA_Plot4.R
File metadata and controls
28 lines (20 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Loading NEI and SSC Data frames:
NEI <- readRDS("summarySCC_PM25.rds")
SCC <- readRDS("Source_Classification_Code.rds")
#Filtering the NEI data related to coal combustion:
combustion <- grepl("comb", SCC$SCC.Level.One, ignore.case = TRUE)
coal <- grepl("coal", SCC$SCC.Level.Four, ignore.case = TRUE)
Coal_Combustion <- (combustion & coal)
combustion_SCC <- SCC[Coal_Combustion, ]$SCC
combustion_NEI <- NEI[NEI$SCC %in% combustion_SCC, ]
#Saving the analysis in PNG:
png("EDA_Plot4.png", width=1280, height=1024, units = "px")
#Plotting the change in coal combustion related emission over the years:
library(ggplot2)
coalcombustion_plot <- ggplot(combustion_NEI, aes(factor(year), Emissions/10^5)) +
geom_bar(stat="identity", fill="blue", width=0.5) +
theme_bw() + guides(fill=FALSE) +
labs(x = "year", y = expression("Total PM2.5 Emissions (10^5 Tons)")) +
labs(title = expression("PM2.5 Coal combustion emissions across USA"))
print(coalcombustion_plot)
dev.off()