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
26 lines (23 loc) · 978 Bytes
/
Copy pathplot1.R
File metadata and controls
26 lines (23 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# ******************************************
# STEP 01 - IMPORT OF DATA & SUBSETTING
#
# Prequirement:
# (a) source data is downloaded and saved in folder "Data"
# https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip
#
# ******************************************
dataFile <- "./Data/household_power_consumption.txt"
data <- read.table(dataFile, header=TRUE, sep=";", stringsAsFactors=FALSE, dec=".")
subSetData <- data[data$Date %in% c("1/2/2007","2/2/2007") ,]
# ****************************************
# STEP 02 - DATA ENRICHMENT
#
# ****************************************
globalActivePower <- as.numeric(subSetData$Global_active_power)
# ****************************************
# STEP 03 - CREATE PLOT
#
# ****************************************
png("plot1.png", width=480, height=480)
hist(globalActivePower, col="red", main="Global Active Power", xlab="Global Active Power (kilowatts)")
dev.off()