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
23 lines (11 loc) · 613 Bytes
/
plot2.R
File metadata and controls
23 lines (11 loc) · 613 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Getting full dataset
data <- read.csv("./Data/household_power_consumption.txt", header=T, sep=“;" , na.strings=“?", stringsAsFactors=F, comment.char="", quote='\"')
## Subsetting the data
subSetData <- data[data$Date %in% c("1/2/2007","2/2/2007") ,]
#str(subSetData)
datetime <- strptime(paste(subSetData$Date, subSetData$Time, sep=" "), "%d/%m/%Y %H:%M:%S")
globalActivePower <- as.numeric(subSetData$Global_active_power)
## Plot 2
plot(datetime, globalActivePower, type="l", xlab="", ylab="Global Active Power (kilowatts)”)
dev.copy(png, file="plot2.png", height=480, width=480)
dev.off()