forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot3.R
14 lines (14 loc) · 970 Bytes
/
Plot3.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
library(dplyr)
library(lubridate)
electricity<-read.csv("household_power_consumption.txt",header = TRUE, sep=";")
electricity$Date<-paste(electricity$Date,electricity$Time)
electricity<-mutate(electricity,Date=as.POSIXct(Date,format="%d/%m/%Y %H:%M:%OS"))
electricity <- subset( electricity, select = -Time )
small_electricity<-filter(electricity,year(electricity$Date)==2007 & month(electricity$Date)==02 & (day(electricity$Date)==01| day(electricity$Date)==02))
png(filename="Plot3.png",width = 480, height = 480)
par(pty="s")
plot(small_electricity$Date,small_electricity$Sub_metering_1,type = 'l',col= 'black', ylab= "Energy Sub Metering",xlab = '')
lines(small_electricity$Date,small_electricity$Sub_metering_2,type = 'l',col= 'red',xlab = '')
lines(small_electricity$Date,small_electricity$Sub_metering_3,type = 'l',col= 'blue',xlab = '')
legend("topright", c("Sub_metering_1","Sub_metering_2","Sub_metering_3"),lty=c(1,1,1),col=c("black","red","blue"))
dev.off()