forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_data.R
More file actions
23 lines (15 loc) · 679 Bytes
/
Copy pathread_data.R
File metadata and controls
23 lines (15 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
url <- 'https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip'
zipFile <- 'household_power_consumption.zip'
destFile <- 'household_power_consumption.txt'
if (!file.exists(destFile)) {
if (!file.exists(zipFile))
download.file(url, zipFile)
unzip(zipfile = zipFile)
}
library(sqldf)
classes <- c("character", "character", replicate(7, "numeric"))
d <- read.csv.sql(destFile, sql="select * from file where Date in ('1/2/2007', '2/2/2007')",
header = TRUE,
sep=";",
colClasses = classes)
d$DateTime <- strptime(paste(d$Date, d$Time, sep=" "), format="%d/%m/%Y %H:%M:%S")