-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlot4.r
More file actions
23 lines (15 loc) · 860 Bytes
/
Plot4.r
File metadata and controls
23 lines (15 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(ggplot2)
Data <- readRDS("C:/Users/SUN/Documents/R Studio Scripts/Course4 Project/summarySCC_PM25.RDS")
DataSumm <-readRDS("C:/Users/SUN/Documents/R Studio Scripts/Course4 Project/Source_Classification_Code.RDS")
Data$year <- as.factor(Data$year)
DataTot <- merge(Data,DataSumm, by ="SCC")
CombRelated <- grepl("Comb",DataSumm$SCC.Level.One)
CoalRelated <- grepl("Coal",DataSumm$SCC.Level.Four)
CoalAndComb <- (CombRelated & CoalRelated)
Sources <- DataSumm[CoalAndComb,]$SCC
MainCombSub <- Data[Data$SCC %in% Sources ,]
png("plot4.png",width=700,height=226 ,units="px")
g <- ggplot(data = MainCombSub, aes(year,Emissions))
p <-(g+ geom_point() +geom_bar(stat="identity",fill="light green",width=0.2) + facet_grid(~type) + geom_smooth(method = 'lm') + theme_dark() + labs(x="Year", y=expression("PM"[2.5]*" Emission")))
print(p)
dev.off()