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
20 lines (14 loc) · 694 Bytes
/
plot1.R
File metadata and controls
20 lines (14 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
##set the workiing directory in the folder where the data resides
## store the scripts in the same dir with the data -- scripts expect to find the data in the same dir
####plot1
#-- download and read the data as a txt file
epc <- read.table("./household_power_consumption.txt", sep=";", header=TRUE, na.strings="?")
##subset the data
lines <- which (epc$Date %in% c('1/2/2007','2/2/2007'))
dataToWork <- epc[lines, ]
## plot and save the graph as a png file
png(filename = "./plot1.png", width = 480, height = 480)
hist(dataToWork$Global_active_power, col="red", ylab="Frequency",
xlab="Global Active Power (kilowatts)", main="Global Active Power" )
## close the device
dev.off()