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
12 lines (12 loc) · 771 Bytes
/
plot2.R
File metadata and controls
12 lines (12 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
url <- "https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip"
download.file(url, destfile="data.zip", method="curl")
unzip("data.zip")
df <- read.csv("household_power_consumption.txt", sep=";", stringsAsFactors = F, header = F, skip=66637, nrows=2880, na.strings="?")
df_header <- read.csv("household_power_consumption.txt", sep=";", stringsAsFactors = F, header = T, nrows=1)
colnames(df) <- colnames(df_header)
df$Date <- strptime(paste(df$Date, df$Time), format="%d/%m/%Y %H:%M:%S")
df <- df[,names(df) != "Time"]
colnames(df)[1] <- "Date_time"
png(filename="plot2.png", width=480, height=480, units="px", bg="transparent")
plot(df$Date_time, df$Global_active_power, xlab="", ylab="Global Active Power (kilowatts)", type="l")
dev.off()