-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot3.R
More file actions
17 lines (15 loc) · 822 Bytes
/
Copy pathplot3.R
File metadata and controls
17 lines (15 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
library(datasets)
data <- read.table("household_power_consumption.txt", sep=";", header = TRUE)
retval <- subset(data,Date %in% c("1/2/2007","2/2/2007"))
retval$Date <- as.Date(retval$Date, format="%d/%m/%Y")
datetime <- paste(as.Date(retval$Date), retval$Time)
retval$Datetime <- as.POSIXct(datetime)
png("plot3.png", width=480, height=480)
plot(as.numeric(as.character(retval$Sub_metering_1))~retval$Datetime,type="l", xlab="",ylab="Energy sub metering",col="black")
lines(as.numeric(as.character(retval$Sub_metering_2))~retval$Datetime,type="l",col="red")
lines(as.numeric(as.character(retval$Sub_metering_3))~retval$Datetime,type="l",col="blue")
legend('topright','groups'
,c("Sub_metering_1","Sub_metering_2","Sub_metering_3"),
lty = 1,
col=c('black','red','blue'))
dev.off()