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) · 639 Bytes
/
plot1.R
File metadata and controls
13 lines (11 loc) · 639 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
library(data.table)
all <- fread('household_power_consumption.txt', na.strings=c("?"), colClasses=c('character', 'character', rep('numeric',7)))
## create a subset for the given 2 days
days <- subset(all, all$Date == '1/2/2007' | all$Date == '2/2/2007')
## for some reason the numerics were still converted to characters even with na.strings attributes
## so cast the values to numerics
days$Global_active_power <- as.numeric(days$Global_active_power)
## print it to file.
png("plot1.png", width = 480, height = 480)
hist(days$Global_active_power, xlab = 'Gobal Active Power (kilowatts)', col="red", main='Global Active Power')
dev.off()