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
25 lines (18 loc) · 970 Bytes
/
Copy pathplot1.R
File metadata and controls
25 lines (18 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#LOAD DATA
# Unzipped data file saved as "data/household_power_consumption.txt"
filename <- file.path("data", "household_power_consumption.txt")
# Subsetting the data for the two days of interest directly to avoid memory
# issues with storing the whole dataset in memory
data_two_days <- subset(read.csv(filename, sep=";", na.strings="?",
stringsAsFactors=FALSE),
Date %in% c("1/2/2007", "2/2/2007"))
# Create a new column datetime in POSIXlt class format from
# Date and Time columns
data_two_days$datetime = strptime(paste(data_two_days$Date,
data_two_days$Time, sep = " "),
format = "%d/%m/%Y %T")
# PLOT DATA
png(filename = "plot1.png", width = 480, height = 480, bg = "transparent")
hist(data_two_days$Global_active_power, col = "red",
main = "Global Active Power", xlab = "Global Active Power (kilowatts)")
dev.off()