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
22 lines (14 loc) · 751 Bytes
/
plot1.R
File metadata and controls
22 lines (14 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Read data
## Data begins on row 66638 to 69538
df <- read.table('household_power_consumption.txt',sep=';',na.strings='?',skip=66637,nrows =2880)
## Set first column to Date type
df[,1]<-as.Date(strptime(df[,1],format='%d/%m/%Y'))
## set names to columns
names(df)<- c("Date","Time","Global Active Power","Global Reactive Power","Voltage","Global Intensity","Kitchen","Laundry","Air and Heat")
df[,"Global Active Power"]<- as.numeric(df[,"Global Active Power"])
## Save file to png
png(filename = "./plot1.png", width = 480, height = 480, units = "px", pointsize = 12, bg = "white")
##plot histogram
with(df,hist(df[,"Global Active Power"],col="RED",main="Global Active Power",xlab='Global Active Power (killowatts)'))
##Close file
dev.off()