forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot2.R
More file actions
26 lines (21 loc) · 666 Bytes
/
plot2.R
File metadata and controls
26 lines (21 loc) · 666 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
library(dplyr)
library(lubridate)
power_consumption <- read.table("household_power_consumption.txt",
header = TRUE,
sep = ";",
na.strings = "?")
power_consumption$Date <- as.Date(strptime(power_consumption$Date, "%d/%m/%Y",
tz = "UTC"))
power_plot <- subset(power_consumption,
Date < as.Date("2007-02-03") & Date > as.Date("2007-01-31"))
power_plot <- mutate(power_plot,
Datetime = ymd_hms(paste(power_plot$Date, power_plot$Time)))
# To create second plot
png(file = "plot2.png",
width = 480,
height = 480)
with(power_plot, plot(Global_active_power~Datetime,
type = "l",
xlab = "",
ylab = "Global Active Power (kilowatts)"))
dev.off()