forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot1.R
More file actions
27 lines (22 loc) · 698 Bytes
/
plot1.R
File metadata and controls
27 lines (22 loc) · 698 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
26
27
library(dplyr)
library(lubridate)
power_consumption <- read.table("household_power_consumption.txt",
header = TRUE,
sep = ";",
na.strings = "?")
power_consumption$Date <- as.Date(strptime(power_consumption$Date, "%d/%m/%Y",
tz = "UTC"))
power_plot <- subset(power_consumption,
Date < as.Date("2007-02-03") & Date > as.Date("2007-01-31"))
power_plot <- mutate(power_plot,
Datetime = ymd_hms(paste(power_plot$Date, power_plot$Time)))
# To create the first plot
png(file = "plot1.png",
width = 480,
height = 480)
hist(power_plot$Global_active_power,
col = "red",
main = "Global Active Power",
xlab = "Global Active Power (kilowatts)",
ylab = "Frequency")
dev.off()