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
13 lines (11 loc) · 665 Bytes
/
plot1.R
File metadata and controls
13 lines (11 loc) · 665 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
# Get file, unzip and import data
temp <- tempfile()
download.file("https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip", temp)
data <- read.table(unz(temp, "household_power_consumption.txt"), header=T, sep = ";", na.strings = "?", stringsAsFactors=FALSE)
unlink(temp)
# Subset data as described in assignment
data <- data[data$Date %in% c("1/2/2007","2/2/2007") ,]
# Write plot to PNG graphics device
png(filename = "plot1.png", width = 480, height = 480, units = "px", bg = "transparent")
hist(data$Global_active_power, main="Global Active Power", xlab="Global Active Power (kilowatts)", ylab="Frequency", col="red")
dev.off()