-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot1.R
More file actions
23 lines (16 loc) · 768 Bytes
/
plot1.R
File metadata and controls
23 lines (16 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#load sqldf liberary
options(gsubfn.engine = "R")
library(sqldf)
#reading data from the dates 2007-02-01 and 2007-02-02.
data<- read.csv.sql("household_power_consumption.txt", sql = "SELECT * from file
WHERE Date in ('1/2/2007','2/2/2007') ", sep = ";", header = TRUE)
#Remove the rows where Global_active_power is NA
data<-data[data$Global_active_power !="?",]
#png Open png device; create "plot1.png" in my working directory
png(file = "plot1.png")
## Create plot and send to a file
hist(data$Global_active_power, main = "Global Active Power", ylab = "Frequency",
xlab = "Global Active Power (kilowatts)", col = "red", breaks = 13,
ylim = c(0,1200), xlim = c(0, 6), xaxp = c(0, 6, 3), yaxp=c(0,1200,6) )
## Close the PNG file device
dev.off()