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
20 lines (14 loc) · 599 Bytes
/
plot2.R
File metadata and controls
20 lines (14 loc) · 599 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#read data
powerdata <- read.csv("./R/project4/power1/household_power_consumption.txt", sep=";")
#subset by year
powerdata <- subset(powerdata, Date=="1/2/2007" | Date=="2/2/2007")
marks1 <- seq(from = 0, to = 6, by = 2)
xax <- as.POSIXct(paste(powerdata$Date, powerdata$Time, sep= " "), format = "%d/%m/%Y %H:%M:%S")
#plot graph
powerdata$Global_active_power <- as.numeric(powerdata$Global_active_power)
png(filename="plot2.png",
width=480,
height=480)
plot(xax, powerdata$Global_active_power, type="l", ylab="Global Active Power (kilowatts)", xlab="")
axis(2,at=marks1)
dev.off()