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
27 lines (21 loc) · 693 Bytes
/
plot1.r
File metadata and controls
27 lines (21 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#load the sqldf package
require("sqldf")
#Set the work directory
setwd("D:/Tue/Coursera/datascience/exploratory/");
#Create a query to select only the required dates
mySql <- "SELECT * from file WHERE Date = '1/2/2007' OR Date = '2/2/2007'"
#Set the filename
myFile <- "household_power_consumption.txt"
#Get the required data
myData <- read.csv.sql(myFile, sql=mySql, sep=";")
#Set the general settings, number of graphs and the fontsize
par(mfrow=c(1,1))
par(cex=0.8)
#Create a histogram
hist(myData$Global_active_power,
xlab="Global Active Power (kilowatts)",
main="Global Active Power",
col="red")
#Save the histogram as plot1.png
dev.copy(png, "plot1.png")
dev.off()