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
18 lines (16 loc) · 640 Bytes
/
plot2.R
File metadata and controls
18 lines (16 loc) · 640 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
##Collect tools
library(data.table)
library(dplyr)
library(lubridate)
##Read data
power <- fread("household_power_consumption.txt", na.strings = '?'
,colClasses = list(character = 1:9))
power <- filter(power, Date == "1/2/2007" | Date == "2/2/2007")
power <- mutate(power, Timestamp = dmy(Date) + hms(Time))
power <- mutate_each(power, funs(as.numeric), -c(Date, Time, Timestamp))
power <- select(power, -Date, -Time)
##Print plot to PNG (480px is the default size)
png(filename = "plot2.png")
plot(power$Timestamp, power$Global_active_power, type = "l",
ylab = "Globla Active Power (kilowatts)", xlab = "")
dev.off()