-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot1.R
More file actions
49 lines (38 loc) · 974 Bytes
/
plot1.R
File metadata and controls
49 lines (38 loc) · 974 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#Reference UDFs
source("./udf.R")
#Define function for building the plot png file
plot1 <- function(dframes=NULL){
packages <- c("dplyr")
packagechecks <- checkPackages(packages)
#Get list of data elements
if(is.null(dframes)){
dframes <- loaddata()
}
#extract data frames from list
pmdf <- data.frame(dframes[1])
summary <- data.frame(dframes[2])
#Begin Analysis
emissions.by.year <- aggregate(summary$Emissions,
by = list(summary$year),
FUN = "sum")
emissions.by.year <- dplyr::rename(emissions.by.year,
yr = Group.1,
pm25 = x)
# Set bg color transparent
par(bg = "transparent")
# Start device
png(file = "plot1.png", width=1200, height=800)
# Draw plot 1
with(emissions.by.year,
plot(emissions.by.year$yr, emissions.by.year$pm25,
type = "l",
main = "PM25 Emissions By Year",
xlab="Year",
ylab="PM25 Emissions")
)
# Close the device
dev.off()
}
#Call the Function
plot1()
#Answer, YES, emissions have decreased