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
13 lines (12 loc) · 761 Bytes
/
Copy pathplot1.R
File metadata and controls
13 lines (12 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
data <- fread("./household_power_consumption.txt", header=FALSE, sep=";", na.strings="?", skip=66637, nrows = 2880)
labels <- fread("./household_power_consumption.txt", header=FALSE, sep=";", nrows = 1)
setnames(data,as.character(labels))
data[,DateTime:=paste(data$Date,data$Time)]
setcolorder(data, c("DateTime","Global_active_power","Global_reactive_power","Voltage","Global_intensity","Sub_metering_1", "Sub_metering_2", "Sub_metering_3","Date","Time"))
data[,Date:=NULL]
data[,Time:=NULL]
data$DateTime <- as.POSIXct(strptime(data$DateTime, "%d/%m/%Y %H:%M:%S"))
library(datasets)
png(filename = "./plot1.png", width=480, height=480)
hist(data$Global_active_power, xlab = "Global Active Power (kilowatts)", main="Global Active Power", col="red")
dev.off()