-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.R
More file actions
20 lines (12 loc) · 660 Bytes
/
plot2.R
File metadata and controls
20 lines (12 loc) · 660 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#set working directory with the source data file
setwd("D:/Dimon/Coursera/Exploratory Data Analysis/project1")
#read the source data file
x<-read.csv2("household_power_consumption.txt",sep=";")
png(filename = "plot2.png", width = 480, height = 480)
#extract data for two days
data <- subset(x,Date == "1/2/2007" | Date == "2/2/2007")
data$Time = strptime(paste(data$Date, data$Time), "%d/%m/%Y %H:%M:%S")
Sys.setlocale("LC_TIME","en_US.UTF-8") # Depends on the system, works for me on my OS
plot(data$Time, data$Global_active_power, type = "n", ylab = "Global Active Power (kilowatts)", xlab="")
lines(data$Time, data$Global_active_power)
dev.off()