forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot1.R
22 lines (18 loc) · 827 Bytes
/
plot1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
data <- read.table('household_power_consumption.txt', sep=';', header=T,
colClasses = c('character', 'character', 'numeric',
'numeric', 'numeric', 'numeric',
'numeric', 'numeric', 'numeric'),
na.strings='?')
# strip the data time
data$DateTime <- strptime(paste(data$Date, data$Time),
"%d/%m/%Y %H:%M:%S")
# set the data time for the days 1 & 2 of month 02
data <- subset(data, as.Date(DateTime) >= as.Date("2007-02-01") &
as.Date(DateTime) <= as.Date("2007-02-02"))
# open a '.png' file
png("plot1.png", height=500, width=500)
hist(data$Global_active_power, col='red',
xlab = 'Global Active Power (kilowatts)',
main = 'Global Active Power')
# close
dev.off()