forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot3.R
19 lines (14 loc) · 838 Bytes
/
Plot3.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
library(dplyr)
library(tidyr)
library(magrittr)
setwd("~/Dropbox/R/Exploratory Data Analysis/Course Project 1/")
energy <- read.table('household_power_consumption.txt',sep = ";",header = T,
stringsAsFactors = F, na.strings = "?")
energy$Date_Time <- as.POSIXct(strptime(paste(energy$Date,energy$Time), "%d/%m/%Y %H:%M:%S"))
energy_Jul <- energy %>% filter((Date_Time >= "2007-02-01") & (Date_Time < "2007-02-03"))
op <- par(cex=.64)
with(energy_Jul, plot(y = Sub_metering_1 , x = Date_Time, type = "l", ylab = "Energy sub metering"))
with(energy_Jul, lines(y = Sub_metering_2, x = Date_Time, col = "red"))
with(energy_Jul, lines(y = Sub_metering_3, x = Date_Time, col = "blue"))
legend("topright", lty = 1,col = c("black","red","blue"),
legend =c("Sub_metering_1","Sub_metering_2","Sub_metering_3"))