forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot2.R
26 lines (19 loc) · 1.08 KB
/
plot2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
fullData <- read.table("household_power_consumption.txt", sep = ";", header = TRUE, colClasses = "character", stringsAsFactors = FALSE)
dfHPC <- subset(fullData, Date == "1/2/2007" | Date == "2/2/2007" )
rm(fullData)
tmpLocale <- Sys.getlocale(category = "LC_TIME")
Sys.setlocale(category = "LC_TIME", "English")
dfHPC$Date <- as.character(dfHPC$Date)
dfHPC$Time <- as.character(dfHPC$Time)
dfHPC$DateTime <- paste(dfHPC$Date, dfHPC$Time)
dfHPC$DateTime <- strptime(dfHPC$DateTime, "%d/%m/%Y %H:%M:%S")
dfHPC$Global_active_power <- as.numeric(dfHPC$Global_active_power)
dfHPC$Global_reactive_power <- as.numeric(dfHPC$Global_reactive_power)
dfHPC$Voltage <- as.numeric(dfHPC$Voltage)
dfHPC$Sub_metering_1 <- as.numeric(dfHPC$Sub_metering_1)
dfHPC$Sub_metering_2 <- as.numeric(dfHPC$Sub_metering_2)
dfHPC$Sub_metering_3 <- as.numeric(dfHPC$Sub_metering_3)
png(filename = "plot2.png", width = 480, height = 480, bg = "transparent")
plot(dfHPC$DateTime, dfHPC$Global_active_power, type = "s", xlab = "", ylab = "Global Active Power (kilowatts)")
dev.off()
Sys.setlocale(category = "LC_TIME", tmpLocale)