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
17 lines (15 loc) · 752 Bytes
/
plot2.R
File metadata and controls
17 lines (15 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Read in records for the 2-day period only, and update column names
data=read.csv2('household_power_consumption.txt',dec='.',
na.strings = "\\?", stringsAsFactors=F,
skip=66637,header=F,nrows=2880)
names(data)=names(read.csv2('household_power_consumption.txt',
header=T,nrows=1) )
# Merge Date and Time to generate new Time in POSIXlt type,
# and convert Date to date type.
data$Time=strptime(with(data,paste(Date,Time)),format='%d/%m/%Y %H:%M:%S')
data$Date=as.Date(data$Date,format="%d/%m/%Y")
# Generate plot and output to png file
png('plot2.png',width = 480, height = 480)
plot(data$Time,data$Global_active_power,type='l',
xlab="",ylab="Global Active Power (kilowatts)" )
dev.off()