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
24 lines (16 loc) · 887 Bytes
/
plot2.R
File metadata and controls
24 lines (16 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Creates the second plot
#Load all the datat into memory; this machine's memory exceeds the requirements so just read everything in
data <- read.table('household_power_consumption.txt', header=TRUE, sep=';', na.strings='?')
#Format our dataset as necessary for further analysis
data$Date <- as.Date(data$Date , "%d/%m/%Y")
data$Time <- paste(data$Date, data$Time, sep=" ")
data$Time <- strptime(data$Time, "%Y-%m-%d %H:%M:%S")
#Subset Our Data
data <- subset(data,Time$year==107 & Time$mon==1 & (Time$mday==1 | Time$mday==2))
#Match date and time together, make things numeric
data$Global_active_power = as.numeric(data$Global_active_power)
#Create the plot as required
plotinfo <- as.numeric(data$Global_active_power)
png("plot2.png", width = 480, height = 480)
plot(x=(data$Time),y=data$Global_active_power,type="l",ylab="Global Active Power (kilowatts)",xlab="")
dev.off()