forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot2.R
More file actions
17 lines (14 loc) · 725 Bytes
/
plot2.R
File metadata and controls
17 lines (14 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
data <- read.csv ( "household_power_consumption.txt", sep = ";" , header= TRUE, stringsAsFactors = FALSE, na.strings = "?")
data$dttm <- paste(data$Date , data$Time , sep = " " )
data$conversion <- strptime( data$dttm , format="%d/%m/%Y %H:%M:%S")
data[,3] <- as.numeric(data[,3])
data[,4] <- as.numeric(data[,4])
data[,5] <- as.numeric(data[,5])
data[,6] <- as.numeric(data[,6])
data[,7] <- as.numeric(data[,7])
data[,8] <- as.numeric(data[,8])
data[,9] <- as.numeric(data[,9])
x <- data[data$Date == "1/2/2007" | data$Date == "2/2/2007", ]
png ( filename="plot2.png" , width=480, height=480)
with(x, plot(conversion, Global_active_power,type="l", ylab= "Global Active Power(killowatts)", main = "" , xlab= ""))
dev.off()