-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEDA_Plot5.R
More file actions
29 lines (20 loc) · 1 KB
/
Copy pathEDA_Plot5.R
File metadata and controls
29 lines (20 loc) · 1 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
29
# Loading NEI and SSC Data frames:
NEI <- readRDS("summarySCC_PM25.rds")
SCC <- readRDS("Source_Classification_Code.rds")
#Filtering the NEI data related to vehicles:
vehicles <- grepl("vehicle", SCC$SCC.Level.Two, ignore.case = TRUE)
vehicles_SCC <- SCC[vehicles, ]$SCC
vehicles_NEI <- NEI[NEI$SCC %in% vehicles_SCC, ]
#Filtering the NEI data related to vehicles in Baltimore city:
vehicles_Baltimore_NEI <- vehicles_NEI[vehicles_NEI$fips == "24510", ]
#Saving the analysis in PNG:
png("EDA_Plot5.png", width=1280, height=1024, units = "px")
#Plotting the change in vehicle emissions in Baltimore city:
library(ggplot2)
vehicles_plot <- ggplot(vehicles_Baltimore_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 vehicle emissions in Baltimore city, Maryland"))
print(vehicles_plot)
dev.off()