forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.R
More file actions
18 lines (16 loc) · 622 Bytes
/
plot2.R
File metadata and controls
18 lines (16 loc) · 622 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
prepareFile <- function(filename){
require(sqldf) # install.packages("sqldf") if missing
df <- read.csv.sql(file = filename,header = TRUE, sql = "select * from file where Date='1/2/2007' or Date='2/2/2007'",sep=";")
df[,10] <- paste(df$Date,df$Time,sep=' ')
dates <- strptime(df[,10],"%d/%m/%Y %H:%M:%S")
df$fulldate = dates
df
}
generatePlot2<- function(df){
plot(df$fulldate,df$Global_active_power,type="n",ylab = "Global active power (kilowatts)", xlab = '')
lines(df$fulldate,df$Global_active_power)
}
df <- prepareFile("household_power_consumption.txt")
png("plot2.png")
generatePlot2(df)
dev.off()