forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot4.R
More file actions
24 lines (20 loc) · 1.36 KB
/
plot4.R
File metadata and controls
24 lines (20 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
fileURL <- 'https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip'
download.file(fileURL, destfile='data/data_extract.zip')
unzip("data/data_extract.zip", exdir="data")
data <- read.delim("data/household_power_consumption.txt", sep=";", na.strings="?")
library(dplyr)
library(lubridate)
#cleaning dates format so that it can be merged with time and into a datetime column
filteredData <- filter(data, grepl("^[12]/2/2007", Date))
filteredData["Date"] <- lapply(filteredData["Date"],function(x){strptime(as.Date(x,format="%d/%m/%Y"), format="%Y-%m-%d")})
filteredData$dateTime<- as.POSIXct(paste(filteredData$Date, filteredData$Time), format="%Y-%m-%d %H:%M:%S")
fileURL <- 'https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip'
download.file(fileURL, destfile='data/data_extract.zip')
unzip("data/data_extract.zip", exdir="data")
data <- read.delim("data/household_power_consumption.txt", sep=";", na.strings="?")
library(dplyr)
library(lubridate)
#cleaning dates format so that it can be merged with time and into a datetime column
filteredData <- filter(data, grepl("^[12]/2/2007", Date))
filteredData["Date"] <- lapply(filteredData["Date"],function(x){strptime(as.Date(x,format="%d/%m/%Y"), format="%Y-%m-%d")})
filteredData$dateTime<- as.POSIXct(paste(filteredData$Date, filteredData$Time), format="%Y-%m-%d %H:%M:%S")