-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot3.R
15 lines (13 loc) · 915 Bytes
/
plot3.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
library(dplyr)
Household <- read.csv(file = "C:/Users/johns/Documents/R/household_power_consumption.txt", header = TRUE, sep = ";", na.strings = "?", nrows=2075259, check.names = F, stringsAsFactors = F, comment.char = "")
subset_household <- subset(Household, Date %in% c("1/2/2007","2/2/2007"))
subset_household$Date <- as.Date(subset_household$Date, format="%d/%m/%Y")
datetime <- paste(as.Date(subset_household$Date), subset_household$Time)
subset_household$Datetime <- as.POSIXct(datetime)
with(subset_household, {plot(Sub_metering_1~Datetime, type="l", ylab="Global Active Power(kilowatts)", xlab="")
lines(Sub_metering_2~Datetime, col="red")
lines(Sub_metering_3~Datetime, col="blue")
})
legend("topright", col=c("black", "red", "blue"), lty=1, lwd=2, legend=c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"))
dev.copy(png, file="plot3.png", height=480, width=480)
dev.off()