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
26 lines (18 loc) · 745 Bytes
/
Copy pathplot2.R
File metadata and controls
26 lines (18 loc) · 745 Bytes
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
# get data
nameOfData <- read.table("household_power_consumption.txt",
nrow=1,sep=";")
d <- read.table("household_power_consumption.txt",
skip=65500,nrow=5000,sep=";",na.strings = "?")
d$V1 <- as.Date(d$V1,format="%d/%m/%Y")
d$V2 <- as.character(d$V2)
names(d) <- unlist(nameOfData[1,])
library(dplyr)
d <- filter(d,Date>=as.Date("2007-02-01") & Date <= as.Date("2007-02-02"))
d <- mutate(d,datetime=paste(Date,Time,sep=" "))
d$datetime <- strptime(d$datetime,format = "%Y-%m-%d %H:%M:%S")
# plot
png(filename='plot2.png',width = 480,height = 480)
plot(d$datetime,d$Global_active_power,type = "n",xlab="",
ylab = "Global Active Power(kilowatts)")
lines(d$datetime,d$Global_active_power)
dev.off()