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
29 lines (14 loc) · 835 Bytes
/
plot2.R
File metadata and controls
29 lines (14 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
path <- "C:/Users/supriya/Documents/Rtutorial/Exploratory_Data_Analysis/"
setwd(path)
#Read in text file
options(StringsAsFactors=FALSE)
powerdat = read.table("household_power_consumption.txt", col.names = colnames(read.table("household_power_consumption.txt", nrow = 1, header = TRUE, sep=";")), sep=";", colClasses="character", na.strings ="?", skip=66637, nrows=2880)
path <- "C:/Users/supriya/Documents/Rtutorial/Exploratory_Data_Analysis/ExData_Plotting1/"
setwd(path)
#plot2
powerdat$DateTime <- paste(powerdat$Date, powerdat$Time, sep = " ")
powerdat$DateTime <-strptime(powerdat$DateTime, format="%d/%m/%Y %H:%M:%S")
powerdat$DateTime <- as.POSIXct(powerdat$DateTime)
png('plot2.png')
plot(powerdat$DateTime, powerdat$Global_active_power, xlab= "", ylab="Global Active Power (kilowatts)" , type="l")
dev.off()