forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_data.R
More file actions
21 lines (18 loc) · 792 Bytes
/
load_data.R
File metadata and controls
21 lines (18 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Exploratory Data Analysis - Course Project 1
# Load data
# data from: https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip
loaddata <- function() {
filename <- "exdata-data-household_power_consumption/household_power_consumption.txt"
df <- read.table(filename,
header=TRUE,
sep=";",
colClasses=c("character", "character", rep("numeric",7)),
na="?")
# convert date time
df$Time <- strptime(paste(df$Date, df$Time), "%d/%m/%Y %H:%M:%S")
df$Date <- as.Date(df$Date, "%d/%m/%Y")
# filter data from 2007-02-01 to 2007-02-02
dates <- as.Date(c("2007-02-01", "2007-02-02"), "%Y-%m-%d")
df <- subset(df, Date %in% dates)
return(df)
}