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
14 lines (10 loc) · 682 Bytes
/
Copy pathplot1.R
File metadata and controls
14 lines (10 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
## This script assumes that you have downloaded and extracted the file "household_power_consumption.txt" and it is in the correct working directory.
#Read in the Dataset
fullDataset <- read.table("household_power_consumption.txt", sep=";", header=TRUE, stringsAsFactors = FALSE)
#subset the data on the required timeframe
dataSubset <- subset(fullDataset, fullDataset$Date == "1/2/2007" | fullDataset$Date == "2/2/2007")
#make histogram plot to console
hist(as.numeric(dataSubset$Global_active_power), col="red", main="Global Active Power",xlab="Global Active Power (kilowatts)")
#Copy console to png file
dev.copy(png, file = "plot1.png" ,width = 480, height = 480)
dev.off()