forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot2.R
25 lines (19 loc) · 846 Bytes
/
plot2.R
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
## plot2.R
## Read The Full Data into a Data Frame
epcdata <- read.csv("./data/household_power_consumption.txt",sep=";",
na.strings="?")
## Extract data for 1st and 2nd of February 2007
usedata <- subset(epcdata, Date == "1/2/2007" | Date == "2/2/2007")
## Convert Date strings to date objects
usedata$Date <- as.Date(usedata$Date,format="%d/%m/%Y")
fulldates <- strptime(paste(usedata$Date,usedata$Time),
format="%Y-%m-%d %H:%M:%S")
## Initialize plot parameters
par(mar=c(6,4.5,5,2.5),cex=0.75)
## Plot Power against Time
with(usedata, plot(fulldates,Global_active_power,type="n",
xlab="",ylab="Global Active Power (kilowatts)"))
lines(fulldates,usedata$Global_active_power)
## Save as a PNG File
dev.copy(png,file="plot2.png",width = 480, height = 480, units = "px")
dev.off()