forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot3.R
More file actions
29 lines (18 loc) · 1.01 KB
/
Copy pathplot3.R
File metadata and controls
29 lines (18 loc) · 1.01 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
25
26
27
#20150112
#marklittle
#setwd("D:\\Rѧϰ±Ê¼Ç\\Exploratory Data Analysis\\week 1")
#fileURL<-"https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip"
#download.file(fileURL,destfile="./t1.zip",method="curl",extra="-k")
library(dplyr)
print("--------------")
d1<-read.table("household_power_consumption.txt",colClasses=c("character","character","character","character","character","character","character","character","character"),header=TRUE,sep=";")#
c1<-paste(d1$Date, d1$Time)
c2<-strptime(c1, "%d/%m/%Y %H:%M:%S")
d1<-cbind(d1,rDate=as.Date(c2),rTime=c2)
d2<-subset(d1,subset=(rDate =="2007-02-01" |rDate =="2007-02-02" ))
png("plot3.png",width=480,height=480)
with(d2,plot(rTime,Sub_metering_1,type="l",xlab="",ylab="Energy sub metering",col="black"))
with(d2,lines(rTime,Sub_metering_2,type="l",col="red"))
with(d2,lines(rTime,Sub_metering_3,type="l",col="blue"))
legend("topright",lty=1,col=c("black","red","blue"),legend=c("sub_metering_1","sub_metering_2","sub_metering_3"))
dev.off()