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
17 lines (12 loc) · 794 Bytes
/
plot2.R
File metadata and controls
17 lines (12 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
download.file("http://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip", "power.zip");
hhAll <- read.table(unz("power.zip", "household_power_consumption.txt"), sep=";", header=TRUE, na.strings="?", stringsAsFactors=FALSE);
datetime <- paste(hhAll$Date, hhAll$Time);
strptime(datetime, "%d/%m/%Y %H:%M:%S");
hhAll$datetime <- datetime;
hhAll$Date <- as.Date(hhAll$Date, format="%d/%m/%Y");
tgtDates <- as.Date(c('01/02/2007', '02/02/2007'), format="%d/%m/%Y");
hh <- with(hhAll, subset(hhAll, Date %in% tgtDates));
hh$datetime <- as.POSIXlt(hh$datetime, format="%d/%m/%Y %H:%M:%S");
png("plot2.png", width=480, height=480);
with(hh, plot(datetime,Global_active_power, type="o", col='black', pch="", xlab="", ylab="Global Active Power (kilowatts)"))
dev.off();