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
19 lines (13 loc) · 775 Bytes
/
plot1.R
File metadata and controls
19 lines (13 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require(dplyr)
dataFile <- read.table("./exdata_data_household_power_consumption/household_power_consumption.txt",
header=TRUE, sep=";", na.strings = "?",stringsAsFactors=FALSE)
consolData <- as.POSIXlt(strptime(paste(dataFile$Date, dataFile$Time, sep=" "),
format = "%d/%m/%Y %H:%M:%S"))
datedData <- cbind(consolData, dataFile[,3:9])
names(datedData)[1] <- "Date"
febData <- filter(datedData, Date >= as.POSIXlt("2007-02-01 00:00:00") &
Date < as.POSIXlt("2007-02-03 00:00:00"))
png(file="plot1.png", width = 480, height = 480)
hist(febData$Global_active_power, breaks=12, col="red",
main="Global Active Power", xlab="Global Active Power (kilowatts)")
dev.off()