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
20 lines (15 loc) · 623 Bytes
/
plot1.R
File metadata and controls
20 lines (15 loc) · 623 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
library('lubridate')
setwd("~/R/exdata-034/ExData_Plotting1")
df <- read.csv('./data/household_power_consumption.txt', sep = ";", na.strings = "?")
# Combine date and time fields into POSIXct datetime object
df$datetime <- dmy_hms(paste(df$Date, df$Time))
# subset data from the dates 2007-02-01 and 2007-02-02
data <- df[df$Date == "1/2/2007" | df$Date == "2/2/2007",]
# Plot 1: Global active power frequency histogram
png('plot1.png', width = 480, height = 480)
par(mfrow=c(1,1))
hist(data$Global_active_power,
col="red",
main="Global Active Power",
xlab="Global Active Power (kilowatts)")
dev.off()