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
19 lines (13 loc) · 716 Bytes
/
Copy pathplot2.R
File metadata and controls
19 lines (13 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
### Script to run from the directory where the data is
# setwd("Coursera_Data_science//Course4_Exploratory_Data_Analysis/course_assignment_1/")
Sys.setlocale("LC_TIME", "English")
# Read the data
data<-read.table("household_power_consumption.txt",sep=";",na.strings="?",header=T)
#Convert the date and tie variables to date and time classes
data$Date<-as.Date(data$Date,"%d/%m/%Y")
data<-data[which(data$Date == "2007-02-01" | data$Date == "2007-02-02"),]
data$Time<-strptime(paste(data$Date,data$Time,sep=","), format="%Y-%m-%d,%H:%M:%S",tz="GMT")
png("plot2.png",width=480, height=480)
plot(data$Time,data$Global_active_power, type="l",
main="",ylab="Global Active Power (kilowatts)",xlab="")
dev.off()