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
18 lines (13 loc) · 690 Bytes
/
plot2.R
File metadata and controls
18 lines (13 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
library(datasets)
library(data.table)
#1 read and subset the data
df.project <- fread("./household_power_consumption.txt", sep = ";", header = T, colClasses = 'character')
df.project <- subset(df.project, df.project$Date =="1/2/2007" | df.project$Date =="2/2/2007")
#2 Convert the date and time into date time posix format
dateTime <- as.POSIXlt(paste(as.Date(df.project$Date,format="%d/%m/%Y"), df.project$Time, sep=" "))
#3 Create a png file with required dimentions
png<-png(file = "plot2.png",480,480)
#4 Create the plot
plot(dateTime,df.project$Global_active_power,type = "l", xlab = " ", ylab = "Global Active Power (Kilowatts)")
#5 Dont forget to close the connection
dev.off()