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
19 lines (17 loc) · 722 Bytes
/
Copy pathplot1.R
File metadata and controls
19 lines (17 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
plot1 <- function(pathToDataFile) {
data <- readData(pathToDataFile)
png(file = "plot1.PNG")
hist(data$Global_active_power, main = "Global Active Power",
xlab = "Global Active Power (kilowatts)", ylab = "Frequency",
col = "red")
dev.off();
}
readData <- function(pathToDataFile) {
completeFileName = paste0(pathToDataFile, "/household_power_consumption.txt")
fullData <- read.csv(completeFileName, sep = ";",
na.strings = "?",
colClasses=c(rep("character",2), rep("numeric",7)))
fullData$Date = as.Date(fullData$Date, format = "%d/%m/%Y")
myData <- subset(fullData, Date >= "2007-02-01" & Date <= "2007-02-02" )
myData
}