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) · 687 Bytes
/
plot1.R
File metadata and controls
13 lines (12 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
hpc<-read.csv("household_power_consumption.txt",sep=";",na.strings="?",colClasses=c("character","character","numeric","numeric","numeric","numeric","numeric","numeric","numeric"))
# Reading the file's content
hpc2<-hpc[hpc$Date=='1/2/2007' | hpc$Date=='2/2/2007',]
# Subsetting the file to get the two relevant days
hpc2$Date<-as.Date(hpc2$Date,'%d/%m/%Y')
# Converting the date to a date format
png(filename="plots/plot1.png",width=480,height=480)
# Creating the PNG with the size requested in the requirements
hist(hpc2$Global_active_power,col="red", main="Global Active Power",xlab="Global Active Power (Kilowatts)")
# Generating the histogram
dev.off()
# Closing the output device.