-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlot 2.R
More file actions
18 lines (15 loc) · 842 Bytes
/
Copy pathPlot 2.R
File metadata and controls
18 lines (15 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
D <- read.table("household_power_consumption.txt", header=TRUE, sep=";", na.strings = "?", colClasses = c('character','character','numeric','numeric','numeric','numeric','numeric','numeric','numeric'))
## Format date to Type Date
D$Date <- as.Date(D$Date, "%d/%m/%Y")
## Filter data set from the dates 2007-02-01 and 2007-02-02
D <- subset(D,Date >= as.Date("2007-2-1") & Date <= as.Date("2007-2-2"))
## Combine Date and Time column
DateTime <- paste(D$Date, D$Time)
## Remove Date and Time column
D <- D[ ,!(names(D) %in% c("Date","Time"))]
## Add DateTime column
D <- cbind(DateTime, D)
## Format DateTime(same as strptime format)
D$DateTime <- as.POSIXct(DateTime)
## Figure 2 : Plot
plot(D$Global_active_power~D$DateTime, type="l", ylab = "Global Active Power (kilowatts)", xlab = "DateTime", width =480, height=480)