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
17 lines (16 loc) · 815 Bytes
/
Copy pathplot2.R
File metadata and controls
17 lines (16 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
library(dplyr)
data <- read.table("household_power_consumption.txt",header=TRUE, sep=";", na.strings="?", stringsAsFactors=FALSE)
subdata <- data[(data$Date == "1/2/2007" | data$Date == "2/2/2007"),]
rm(data)
power<-tbl_df(subdata)
## concatenate date and time
power = mutate(power, Date_Time = paste(Date, Time, sep=" "))
## drop the old columns
power<-select(power, Date_Time, Global_active_power:Sub_metering_3)
## transform the strings into date objects
power$Date_Time <- strptime(power$Date_Time, format="%d/%m/%Y %H:%M:%S")
## set locales otherwise we get the day of the week OS locale
Sys.setlocale("LC_TIME", "C")
png(file = "ExData_Plotting1/plot2.png", bg = "transparent")
plot(power$Date_Time, power$Global_active_power , type="l", main = "", xlab="", ylab="Global Active Power (kilowatts)")
dev.off()