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
22 lines (18 loc) · 883 Bytes
/
Copy pathplot2.R
File metadata and controls
22 lines (18 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
##Construct plot2.png
localpath<-"./ExData_Plotting1/"
filename <- "household_power_consumption.txt"
filepath<- paste(localpath,filename,sep="")
data <- read.table(filepath,header=TRUE,sep=";",na.strings="?")
data$Date <- as.Date(data$Date, format = "%d/%m/%Y")
day1 <- subset(data,data$Date == ("2007-02-01"))
day2 <- subset(data,data$Date == ("2007-02-02"))
household.energy <- rbind(day1,day2)
paste(household.energy$Date,household.energy$Time,sep=" ")
household.energy$Time <- strptime(paste(household.energy$Date,household.energy$Time,sep=" "),format = "%Y-%m-%d %H:%M:%S")
for(i in 3:9) {
household.energy[,i] <- as.numeric(household.energy[,i])
}
png(filename="./ExData_Plotting1/plot2.png", width = 480, height = 480)
Sys.setlocale('LC_TIME', 'C')
with(household.energy,plot(Time,Global_active_power,type="l",ylab="Global Active Power (kilowatts)",xlab=" "))
dev.off()