forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot1.R
20 lines (17 loc) · 776 Bytes
/
plot1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
setwd("~/Documents/R/coursera")
datafr <- read.table("household_power_consumption.txt",
+ sep = ";",
+ header=TRUE,
+ na.string=c("?",""))
datafr$Date <- as.Date(datafr$Date, format = "%d/%m/%Y")
str(datafr)
datafr$timetemp <- paste(datafr$Date, datafr$Time)
head(datafr$timetemp)
datafr$Time <- strptime(datafr$timetemp, format = "%Y-%m-%d %H:%M:%S")
str(datafr)
datafr <- subset(datafr, Date >= "2007-02-01" & Date <= "2007-02-02")
head(datafr)
tail(datafr)
with(datafr,hist(Global_active_power,main = "Golbal Active Power", xlab = "Gobal Active Power (kilowatts)", col = "red"))
dev.copy(png, file = "plot1.png")
dev.off()