forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot1.R
More file actions
16 lines (14 loc) · 699 Bytes
/
plot1.R
File metadata and controls
16 lines (14 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#Read the file in, and drop all but the two days we care about
power <- read.table("household_power_consumption.txt", sep=";",
na.strings="?", header=T)
power <- subset(power, Date %in% c("1/2/2007", "2/2/2007"))
#Convert date/time string to a single DateTime object and
#drop the origina Date and Time columns
DateTime = paste(power$Date, power$Time)
DateTime <- strptime(DateTime, "%d/%m/%Y %H:%M:%S")
lv = names(power) != "Date" & names(power) != "Time"
power = cbind(DateTime, power[,lv])
#Plot 1
hist(power$Global_active_power, col="red", main="Global Active Power", xlab="Global Active Power(kilowatts)")
dev.copy(png, file="plot1.png", width=480, height=480)
dev.off()