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 (13 loc) · 683 Bytes
/
plot1.R
File metadata and controls
13 lines (13 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
# read the data, put in a data frame
# we read only 100000 lines, because we know what
dafr = read.table(file="../household_power_consumption.txt",
na.strings="?", sep=";", header=TRUE, nrows=100000 )
# convert to Date , so it will be easier to compare dates
dafr$Date = as.Date(dafr$Date, "%d/%m/%Y")
# extract subset of interest, Feb 1-2, 2007
twodays = dafr[ (dafr$Date>="2007-02-01" ) & (dafr$Date <="2007-02-02"),]
hist(twodays$Global_active_power, main="Global Active Power",
xlab="Global Active Power(kilowatts)", col="red")
# copy the result to png file, default sizes specified, just to be sure
dev.copy(png, file = "plot1.png", width=480, height=480 )
dev.off()