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
13 lines (11 loc) · 742 Bytes
/
plot2.R
File metadata and controls
13 lines (11 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
# plot2.R to plot global active power time series
## Read and subset data for proper dates
data <- read.table('household_power_consumption.txt',na.strings="?",header=T,sep=";",colClasses=c('character','character','numeric',
'numeric', 'numeric', 'numeric','numeric', 'numeric', 'numeric'))
data$DateTime <- strptime(paste(data$Date, data$Time),"%d/%m/%Y %H:%M:%S")
plotData <- subset(data,as.Date(DateTime) <= as.Date("2007-02-02") & as.Date(DateTime) >= as.Date("2007-02-01"))
## Build plot and save png
png("plot2.png",height=504,width=504,bg="transparent")
plot(plotData$DateTime,plotData$Global_active_power,pch=NA,ylab="Global Active Power (kilowatts)",xlab="")
lines(plotData$DateTime,plotData$Global_active_power)
dev.off()