-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot 5.R
More file actions
38 lines (25 loc) · 1.12 KB
/
plot 5.R
File metadata and controls
38 lines (25 loc) · 1.12 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
36
37
38
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")
## Merge the two data sets to find out the Coal as Short.Name
if(!exists("NEISCC")){
NEISCC <- merge(NEI, SCC, by="SCC")
}
library(ggplot2)
## Across the United States, how have emissions from coal
## combustion-related sources changed from 1999-2008?
## find out the subset of coal specific data
subsetBaltimore <- subset(NEISCC, fips == "24510")
totalbyYearBaltimoreType <- aggregate(Emissions ~ year + type, subsetBaltimore, sum)
png('plot4.png', width=640, height = 480)
g <- ggplot(totalbyYearBaltimoreType, aes(factor(year), Emissions))
g <- g + geom_bar(stat="identity") +
xlab("year") +
ylab(expression('Total PM'[2.5]*" Emissions")) +
ggtitle('Total Emissions from coal sources from 1999 to 2008')
print(g)
dev.off()