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
11 lines (9 loc) · 627 Bytes
/
Copy pathplot2.R
File metadata and controls
11 lines (9 loc) · 627 Bytes
1
2
3
4
5
6
7
8
9
10
11
# Read the data
data <- read.table(pipe('grep "^[1-2]/2/2007" "household_power_consumption.txt"'), sep = ";",na.strings = "?")
colnames(data) <- c("Date", "Time", "GlobalActivePower", "GlobalReactivePower", "Voltage", "GlobalIntensity", "SubMetering1", "SubMetering2", "SubMetering3")
# Convert the Date and Time Variables in a new column
data$DateTime <- strptime(paste(data$Date, data$Time), format = "%d/%m/%Y %H:%M:%S")
# plot2
png(filename = "plot2.png", width = 480, height = 480, units = "px", pointsize = 12)
plot(data$DateTime, data$GlobalActivePower, type = "l", ylab = "Global Active Power (kilowatts)")
dev.off()