-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot4.R
33 lines (26 loc) · 933 Bytes
/
plot4.R
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
30
31
32
33
library(ggplot2)
library(sqldf)
library(scales)
## This first line will likely take a few seconds. Be patient!
NEI <- readRDS("summarySCC_PM25.rds")
SCC <- readRDS("Source_Classification_Code.rds")
colnames(NEI)
head(NEI, n=1)
str(unique(NEI$type))
colnames(SCC)
str(unique(SCC$EI.Sector))
summary(SCC)
which(duplicated(SCC$SCC) == T)
p25 <- sqldf('SELECT n.year, n.type,
sum(n.Emissions) as emissions
FROM NEI n
JOIN SCC s ON (n.SCC = s.SCC)
WHERE s.`EI.Sector` like "Fuel Comb%Coal"
GROUP BY year, type')
p25_plot <-
ggplot(p25, aes(x = factor(year), y = emissions, fill = type)) +
geom_bar(stat = "identity", colour="grey50") +
scale_y_continuous(labels = comma) +
geom_smooth(method = "auto", se=F, aes(group=1), color="yellow") +
xlab("Year") + ylab("Total emissions")
suppressMessages(print(p25_plot))