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
23 lines (14 loc) · 678 Bytes
/
Plot1.R
File metadata and controls
23 lines (14 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
library("data.table")
#directory <- paste(getwd(),'Exploratory_Data_Analysis','C4W1','household_power_consumption.txt',sep = '/')
directory <- paste(getwd(),'household_power_consumption.txt',sep = '/')
#importing data
dat <- fread(input = directory, na.strings="?")
# Change Date Column to Date Type
dat[, Date := lapply(.SD, as.Date, "%d/%m/%Y"), .SDcols = c("Date")]
# Filter Dates for 2007-02-01 and 2007-02-02
dat <- dat[(Date >= "2007-02-01") & (Date < "2007-02-03")]
png("plot1.png", width=480, height=480)
## Plot 1
hist(dat[, Global_active_power], main="Global Active Power",
xlab="Global Active Power (kilowatts)", ylab="Frequency", col="Red")
dev.off()