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
16 lines (13 loc) · 661 Bytes
/
Copy pathplot2.R
File metadata and controls
16 lines (13 loc) · 661 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Plot2.R
# Creates a line plot of global active power vs day/time
# Read data
data <- read.table("household_power_consumption.txt",sep=";",header=T,na.strings="?")
data$Date <- strptime(data$Date,format="%d/%m/%Y")
timeLowLim <- as.POSIXct("2007-02-01")
timeUpLim <- as.POSIXct("2007-02-02")
dataSubset <- subset(data,Date >= timeLowLim & Date <= timeUpLim)
dataSubset$DateTime <- strptime(paste(dataSubset$Date,dataSubset$Time,sep=" "),format="%Y-%m-%d %H:%M:%S")
png(filename="plot2.png",width=480,height=480,pointsize=12)
plot(x=dataSubset$DateTime,y=dataSubset$Global_active_power,type="l",
xlab="",ylab="Global Active Power (kilowatts)")
dev.off()