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
15 lines (14 loc) · 639 Bytes
/
Plot1.R
File metadata and controls
15 lines (14 loc) · 639 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require(lubridate)
#read the data in
household<- read.table("household_power_consumption.txt", header=TRUE, sep= ";",na.strings="?",stringsAsFactors= FALSE)
#clean up the table
datetime<- within(household, DateTime <- paste(Date,Time, sep=' '))
household<- datetime[,-c(1:2)]
household<- household[,c(8,1:7)]
#Convert the date and time
household$DateTime <- dmy_hms(household$DateTime)
#Subset
household<- subset(household, DateTime> ymd("2007-02-01") & DateTime < ymd("2007-02-03"))
png('plot1.png')
plot1<- with(household, hist(Global_active_power,col="red",main= "Global Active Power",xlab="Global Active Power (kilowatts)"))
dev.off()