forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot1.R
More file actions
28 lines (22 loc) · 1.18 KB
/
Copy pathplot1.R
File metadata and controls
28 lines (22 loc) · 1.18 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
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("plot1.png")
hist(ePowerConsum_dataSet$Global_active_power,
col = "red",
main = "Global Active Power",
xlab = "Global Active Power (kilowatts)")
dev.off()