-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot3.R
More file actions
30 lines (24 loc) · 891 Bytes
/
plot3.R
File metadata and controls
30 lines (24 loc) · 891 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
27
28
29
30
library(ggplot2)
library(sqldf)
## 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)
summary(SCC)
baltimore_types <- sqldf('SELECT year, type,
sum(Emissions) as emissions
FROM NEI
WHERE fips = "24510"
GROUP BY year, type')
baltimore_plot <-
ggplot(baltimore_types, aes(x = factor(year), y = emissions)) +
geom_bar(stat = "identity", colour="grey50") +
facet_grid(. ~ type) +
geom_smooth(method = "lm", se=F,
color="#73C2FB", aes(group=1), size=0.5) +
xlab("Year") + ylab("Total emissions") +
labs(title="Emissions in Baltimore grouped by type")
baltimore_plot