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
27 lines (17 loc) · 711 Bytes
/
plot1.R
File metadata and controls
27 lines (17 loc) · 711 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
url <- 'https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip'
download.file(url, 'power.zip', mode ='wb')
unzip('power.zip')
power_full <- read.table('household_power_consumption.txt', header=TRUE, sep = ';', na.strings = '?')
##make names lowercase
names(power_full) <- tolower(names(power_full))
library(dplyr)
##select subset of dates we need
##d/m/yyyy
power <- filter(power_full, date == '1/2/2007' | date == '2/2/2007')
##make columns numeric
power[,3:9] <- sapply(power[,3:9], as.numeric)
##make plot
png(filename = 'plot1.png')
hist(power$global_active_power, col = 'red', xlab = 'Global Active Power (kilowatts)',
main = 'Global Active Power')
dev.off()