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
24 lines (19 loc) · 974 Bytes
/
plot2.R
File metadata and controls
24 lines (19 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#LOAD DATA
# Unzipped data file saved as "data/household_power_consumption.txt"
filename <- file.path("data", "household_power_consumption.txt")
# Subsetting the data for the two days of interest directly to avoid memory
# issues with storing the whole dataset in memory
data_two_days <- subset(read.csv(filename, sep=";", na.strings="?",
stringsAsFactors=FALSE),
Date %in% c("1/2/2007", "2/2/2007"))
# Create a new column datetime in POSIXlt class format from
# Date and Time columns
data_two_days$datetime = strptime(paste(data_two_days$Date,
data_two_days$Time, sep = " "),
format = "%d/%m/%Y %T")
# PLOT DATA
png(filename = "plot2.png", width = 480, height = 480, bg = "transparent")
with(data_two_days,
plot(datetime, Global_active_power, type = "l",
xlab = "", ylab = "Global Active Power (kilowatts)"))
dev.off()