-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEDA_Plot3.R
More file actions
26 lines (19 loc) · 1017 Bytes
/
Copy pathEDA_Plot3.R
File metadata and controls
26 lines (19 loc) · 1017 Bytes
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
# Loading NEI and SSC Data frames:
NEI <- readRDS("summarySCC_PM25.rds")
SCC <- readRDS("Source_Classification_Code.rds")
#Filtering the NEI data by Baltimore city:
NEI_Baltimore <- NEI[NEI$fips == "24510", ]
#Finding total emissions by year:
Total_emission_Baltimore <- aggregate(Emissions ~ year, NEI_Baltimore, sum)
#Saving the analysis in PNG:
png("EDA_Plot3.png", width=1280, height=1024, units = "px")
#Plotting the increase in total emissions in the Baltimore city according to the four types of sources:
library(ggplot2)
Type_Plot <- ggplot(NEI_Baltimore, aes(factor(year), Emissions, fill=type)) +
geom_bar(stat = "identity") +
theme_bw() + guides(fill=FALSE) +
facet_grid(.~type, scales = "free", space = "free") +
labs(x = "year", y = expression("PM2.5 Emissions (Tons)")) +
labs(title = expression("Total PM2.5 Emissions across Baltimore city, Maryland according to source type"))
print(Type_Plot)
dev.off()