forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot1.R
More file actions
12 lines (12 loc) · 787 Bytes
/
plot1.R
File metadata and controls
12 lines (12 loc) · 787 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="plot1.png", width=480, height=480, units="px", bg="transparent")
hist(df$Global_active_power, labels=F, main="Global Active Power", xlab="Global Active Power (kilowatts)", col="red")
dev.off()