-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.R
More file actions
23 lines (16 loc) · 877 Bytes
/
plot2.R
File metadata and controls
23 lines (16 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Exploratory Data Analysis - Assignment 2 - Q.2
#setting Working Directory
setwd("C:/Users/Makarand/Desktop/Coursera/project")
# Loading provided datasets from local machine
NEI <- readRDS("summarySCC_PM25.rds")
SCC <- readRDS("Source_Classification_Code.rds")
# Sampling
NEI_sampling <- NEI[sample(nrow(NEI), size=5000, replace=F), ]
# Subsetting data and append two years in one data frame
MD <- subset(NEI, fips=='24510')
# Have total emissions from PM2.5 decreased in the Baltimore City, Maryland (fips == "24510")
# from 1999 to 2008? Use the base plotting system to make a plot answering this question.
# Generate the graph in the same directory as the source code
png(filename='plot2.png')
barplot(tapply(X=MD$Emissions, INDEX=MD$year, FUN=sum),main='Total Emission in Baltimore City, MD',xlab='Year', ylab=expression('PM'[2.5]))
dev.off()