-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.R
More file actions
18 lines (16 loc) · 846 Bytes
/
plot2.R
File metadata and controls
18 lines (16 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#Plot 2
### Get the Data and prep for graphing
household_power_consumption <- read.csv("~/Documents/workspace/PlottingData/household_power_consumption.txt", sep=";", stringsAsFactors = FALSE)
power <- household_power_consumption
power$DateTime <- paste(power$Date, power$Time)
power$DateTime <- strptime(power$DateTime, "%d/%m/%Y %H:%M:%S")
plotdata <- subset(power, DateTime < as.POSIXct('2007-02-03'))
plotdata <- subset(plotdata, DateTime > as.POSIXct('2007-02-01'))
plotdata$Global_active_power <- as.numeric(plotdata$Global_active_power)
#Build the Line Plot
plot(plotdata$DateTime, plotdata$Global_active_power, type="n", xlab="", ylab="")
with(plotdata, lines(DateTime,Global_active_power))
title(ylab="Global Active Power (kilowatts)")
###Create the PNG file
dev.copy(png, file="plot2.png", width=480, height=480, units="px")
dev.off()