forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.R
More file actions
37 lines (28 loc) · 1.21 KB
/
plot2.R
File metadata and controls
37 lines (28 loc) · 1.21 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
#############################################################################
# Exploratory Data Analysis
# John Hopkins University
# Coursera Course Project
# Author: Anand Rao
# Date: 06 Sep 2014
# Project #1
##############################################################################
require(sqldf)
setwd("~/My Courses/ExploratoryDataAnalysis/Projects")
## Read Data for just the dates 1/2/2007 and 2/2/2007
data <- read.csv.sql( file='household_power_consumption.txt',
sep=";",
sql="select * from file where Date = '1/2/2007' or Date = '2/2/2007'",
header=TRUE)
data$datetime <- as.POSIXct(paste(data$Date, data$Time), format = "%d/%m/%Y %T")
## Open PNG device and create a plot "Plot2" in working directory with
## Width of 480 pixels and height of 480 pixels
png(filename="Plot2.png", width=480, height=480)
## Create a base plot frame with a new Y-axis label and X-axis label
with(data, plot(datetime, Global_active_power,
xlab="",
ylab = "Global Active Power (kilowatts)",
type="n"))
## Draw the lines for the graph
with(data, lines(datetime, Global_active_power))
## Close the PNG file device
dev.off()