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
18 lines (14 loc) · 846 Bytes
/
Copy pathplot2.R
File metadata and controls
18 lines (14 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
elec<-read.table("exdata-data-household_power_consumption\\household_power_consumption.txt", sep=";", skip=1,
col.names=c("date", "time", "active_power", "inactive_power", "voltage",
"intensity", "meter1", "meter2", "meter3"),
colClasses=c("character", "character", "character","character", "character",
"character","character", "character", "character"));
sub1<-subset(elec, date=="1/2/2007");
sub2<-subset(elec, date=="2/2/2007");
sub<-rbind(sub1, sub2);
# plot 2
active_power<-as.numeric(sub$active_power);
png("plot2.png",width = 480, height = 480)
plot(active_power, type="l", xaxt="n", xlab="datetime", ylab="Global Active Power (kilowatts)");
axis(1, at=c(1,length(sub$date)/2,length(sub$date)), labels=c("Thu","Fri", "Sat"));
dev.off();