Skip to content

Commit

Permalink
Getting closer to the end:
Browse files Browse the repository at this point in the history
- Plot 1 -> done
- Plot 2 -> done
  • Loading branch information
blavoie committed Nov 19, 2015
1 parent 33b2a1c commit 1bcc256
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
Binary file added .RData
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# ExData_Plotting2
Plotting Assignment 1 for Exploratory Data Analysis
Plotting Assignment 2 for Exploratory Data Analysis
22 changes: 22 additions & 0 deletions plot1.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,25 @@ if (!exists("SCC")) {
SCC <- load.SCC()
}

#
# Have total emissions from PM2.5 decreased in the United States from 1999 to 2008?
#
# Using the base plotting system, make a plot showing the total PM2.5 emission from
# all sources for each of the years 1999, 2002, 2005, and 2008.
#

library(dplyr)

png('plot1.png', width=750, height=750)

with(
NEI %>%
group_by(year) %>%
summarise(emissions = sum(Emissions)),
plot(year, emissions, type = "l",
main = "Fine particulate matter emissions (PM2.5) in the U.S. ",
xlab = "Year",
ylab = "Total emissions in tons")
)

dev.off()
Binary file added plot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions plot2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

# Check if we have data, if not load it!

source("load.data.R")

if (!exists("MEI")) {
NEI <- load.NEI()
}

if (!exists("SCC")) {
SCC <- load.SCC()
}

# 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.

library(dplyr)

png('plot2.png', width=750, height=750)

with(
NEI %>%
filter(fips == "24510") %>%
group_by(year) %>%
summarise(emissions = sum(Emissions)),
plot(year, emissions, type = "l",
main = "Fine particulate matter emissions (PM2.5) in Baltimore City, Maryland",
xlab = "Year",
ylab = "Total emissions in tons")
)

dev.off()
Binary file added plot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1bcc256

Please sign in to comment.