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 (22 loc) · 798 Bytes
/
plot2.r
File metadata and controls
29 lines (22 loc) · 798 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
25
26
27
28
29
library(data.table)
library(chron)
library(lubridate)
full_data <- fread("household_power_consumption.txt",
na.strings = "?")
full_data2 <- subset(full_data, Date == "1/2/2007" | Date == "2/2/2007")
full_data2$DateD <- as.Date(full_data2$Date,"%d/%m/%Y")
full_data2$TimeT <- times(full_data2$Time)
full_data2$DateDT <- ymd_hms(strptime(paste(full_data2$Date,full_data2$Time),"%d/%m/%Y %H:%M:%S"))
# Plot 2
png(filename="plot2.png",
width=480,
height=480)
plot(full_data2$DateDT,full_data2$Global_active_power,
type="l",
xaxt="n",
ylab="Global Active Power (kilowatts)",
xlab="")
axis(1,
at = c(min(full_data2$DateDT),mean(full_data2$DateDT),max(full_data2$DateDT)),
labels = c("Thu","Fri","Sat"))
dev.off()