forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.Rmd
30 lines (26 loc) · 798 Bytes
/
project.Rmd
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
27
28
29
30
---
title: "Exploratory Data Analysis CP1"
author: "Sertinell"
date: "2 November 2015"
output: html_document
---
First we read the data from the file and filter the required Dates.
```{r}
library(data.table)
library(dplyr)
data <- fread("household_power_consumption.txt", header = TRUE,
colClasses = rep("character", 9))
data <- filter(data, (Date == "1/2/2007" | Date == "2/2/2007"))
data <- as.data.frame(data)
```
Now, convert _Date_ and _Time_ columns to a new _datetime_ column and convert it to a DateTime object:
```{r}
data <- mutate(data, datetime = paste(Date, Time))
str(data$datetime)
data$datetime <- strptime(data$datetime, "%e/%m/%Y %T")
```
Convert variables to numeric
```{r}
data[,3:9] <- lapply(data[,3:9], as.numeric)
```
Plots should be created in new files