forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot1.R
13 lines (13 loc) · 857 Bytes
/
Plot1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
library(dplyr)
library(lubridate)
electricity<-read.csv("household_power_consumption.txt",header = TRUE, sep=";")
electricity$Date<-paste(electricity$Date,electricity$Time)
electricity<-mutate(electricity,Date=as.POSIXct(Date,format="%d/%m/%Y %H:%M:%OS"))
electricity <- subset( electricity, select = -Time )
small_electricity<-filter(electricity,year(electricity$Date)==2007 & month(electricity$Date)==02 & (day(electricity$Date)==01| day(electricity$Date)==02))
small_electricity$Global_active_power <- sub(",",".",small_electricity$Global_active_power)
small_electricity$Global_active_power<-as.numeric(small_electricity$Global_active_power)
png(filename="Plot1.png",width = 480, height = 480)
par(pty="s")
hist((small_electricity$Global_active_power),main= "Global active power",xlab= "Global Active Power (kilowatts)", breaks = 12,col="red")
dev.off()