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
27 lines (15 loc) · 805 Bytes
/
plot2.R
File metadata and controls
27 lines (15 loc) · 805 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
### 2nd plot
fileUrl <- "https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip"
download.file(fileUrl, destfile = "gastoElec.zip")
unzip("gastoElec.zip")
tbl <- read.csv("household_power_consumption.txt", header = T,
sep = ';', na.strings = "?", nrows = 2075259,
check.names = F, stringsAsFactors = F,
quote = '\"')
library(dplyr)
tbl_1_2 <- filter(tbl, Date == "1/2/2007" | Date == "2/2/2007")
rm(tbl)
tbl_1_2[, "Date"] <- as.Date(tbl_1_2[, "Date"], format = "%d/%m/%Y")
tbl_1_2$Datetime <- as.POSIXct(paste(tbl_1_2$Date, tbl_1_2$Time))
plot(tbl_1_2$Global_active_power ~ tbl_1_2$Datetime, type = "l",
ylab = "Global Active Power (kilowatts)", xlab = "")