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
29 lines (23 loc) · 1.2 KB
/
Copy pathplot2.R
File metadata and controls
29 lines (23 loc) · 1.2 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
library(data.table)
classes <- c("character", "character",
"numeric", "numeric", "numeric", "numeric",
"numeric", "numeric", "numeric")
ePowerConsum_dataSet <- fread("./household_power_consumption.txt",
header = TRUE,
sep = ";",
na.strings = c("NA", "-", "?"),
stringsAsFactors = FALSE,
colClasses = classes)
selected.dates_Indices <- grep("^[1-2]/2/2007" , ePowerConsum_dataSet$Date)
ePowerConsum_dataSet <- ePowerConsum_dataSet[selected.dates_Indices,]
#ePowerConsum_dataSet$Date <- as.Date(ePowerConsum_dataSet$Date, format = "%d/%m/%Y")
character_date.Time <- paste(ePowerConsum_dataSet$Date, ePowerConsum_dataSet$Time)
date.Time <- as.POSIXct(strptime(character_date.Time, format = "%d/%m/%Y %H:%M:%S"))
ePowerConsum_dataSet <- cbind(date.Time, ePowerConsum_dataSet)
png("plot2.png")
plot(x = ePowerConsum_dataSet$date.Time,
y = ePowerConsum_dataSet$Global_active_power,
type = "l",
ylab = "Global Active Power (kilowatts)",
xlab = "")
dev.off()