forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.R
More file actions
12 lines (9 loc) · 626 Bytes
/
plot2.R
File metadata and controls
12 lines (9 loc) · 626 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
data <- read.csv("household_power_consumption.txt", sep=";", na.strings = "?")
data$Date <- as.Date(data$Date, format="%d/%m/%Y")
dataFiltered <- data[data$Date == "2007-02-01" | data$Date == "2007-02-02",]
dataFiltered$DateTime <- paste(dataFiltered$Date, dataFiltered$Time, sep=":")
dataFiltered$DateTime <- strptime(dataFiltered$DateTime, format="%Y-%m-%d:%H:%M:%S")
png("plot2.png", width = 501, height = 501)
plot(dataFiltered$DateTime,dataFiltered$Global_active_power, main = "", xlab = "", ylab = "Global Active Power (kilowats)", type = "n")
lines(dataFiltered$DateTime, dataFiltered$Global_active_power)
dev.off()