forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot1.R
20 lines (16 loc) · 917 Bytes
/
plot1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
readZip <- function(fname,ename,sep=",",na.strings = "NA") {
temp <- tempfile()
download.file(fname,temp)
data <- read.csv(unz(temp, ename),sep=sep,na.strings=na.strings)
unlink(temp)
data
}
data <- subset(readZip("http://d396qusza40orc.cloudfront.net/exdata/data/household_power_consumption.zip","household_power_consumption.txt",sep=";",na.strings = "?"),Date %in% c("1/2/2007","2/2/2007"))
#data <- subset(read.csv(unz("/tmp/household_power_consumption.zip", "household_power_consumption.txt"),sep=";",na.strings = "?",nrows=-1),Date %in% c("1/2/2007","2/2/2007"))
#data$datetime <- as.POSIXlt(paste(data$Date,data$Time),format="%d/%m/%Y %H:%M:%S")
#data$Date <- NULL
#data$Time <- NULL
# boxplot(data$Global_reactive_power)
png(file="plot1.png",width = 480, height = 480)
hist(data$Global_active_power,freq=TRUE,col="red",main="Global Active Power",xlab="Global Active Power (kilowatts)")
dev.off()