forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot1.R
28 lines (22 loc) · 1.09 KB
/
plot1.R
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
28
# For each plot you should
## - Construct the plot and save it to a PNG file with a width of 480 pixels and a height of 480 pixels.
## - Name each of the plot files as plot1.png, plot2.png, etc.
## - Create a separate R code file (plot1.R, plot2.R, etc.) that constructs the corresponding plot, i.e. code in plot1.R constructs the plot1.png plot.
## Your code file should include code for reading the data so that the plot can be fully reproduced.
## You must also include the code that creates the PNG file.
## - Add the PNG file and R code file to your git repository
#
# decide where to run the script
# convention: data is in /data
# setwd("~/GitRepo/ExData_Plotting1/")
# clean data is available in /data folder
# convention: the /data folder is excluded from git using .gitignore
# moved code for generating clean data to separate routine to ensure identical data in all plots
# see: loading-data.R
load("./Data/data.RData")
png(file = "plot1.png")
hist(result$Global_active_power,
col = "red",
xlab = "Global Active Power (kilowatts)",
main = "Global Active Power")
dev.off()