-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot 3.R
More file actions
35 lines (24 loc) · 1.2 KB
/
plot 3.R
File metadata and controls
35 lines (24 loc) · 1.2 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
30
31
32
33
34
35
dir()
setwd("E:/R Programming/R Coursera/Exploratory Data Analysis/Week 4")
## Loading Data SummarySCC.RDS
if(!exists("NEI"))
NEI <- readRDS("E:/R Programming/R Coursera/Exploratory Data Analysis/Week 4/summarySCC_PM25.rds")
if(!exists("SCC"))
SCC <- readRDS("E:/R Programming/R Coursera/Exploratory Data Analysis/Week 4/Source_Classification_Code.rds")
library(ggplot2)
## Of the four types of sources indicated by the type (point, nonpoint, onroad, nonroad)
## variable, which of these four sources have seen decreases in emissions from 1999-2008 for
## Baltimore City? Which have seen increases in emissions from 1999-2008? Use the ggplot2
## plotting system to make a plot answer this question.
names(SCC)
names(NEI)
subsetBaltimore <- subset(NEI, fips == "24510")
totalbyYearBaltimoreType <- aggregate(Emissions ~ year + type, subsetBaltimore, sum)
png('plot3.png', width=640, height = 480)
g <- ggplot(totalbyYearBaltimoreType, aes(year, Emissions, color = type))
g <- g + geom_line() +
xlab("year") +
ylab(expression('Total PM'[2.5]*" Emissions")) +
ggtitle('Total Emissions in Baltimore City, Maryland (fips == "24510") from 1999 to 2008')
print(g)
dev.off()