-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdivetypes_platform.R
38 lines (28 loc) · 993 Bytes
/
divetypes_platform.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
29
30
31
32
33
34
#' Number of dives per dive platform type
#'
#' Creates a barplot with the number of dives per region and country and platform type
#'
#' This function creates a barplot to visualize the number of dives per region and platform type "poolDive", "boatDive" or "shoreDive"
#'
#' @param path directory location where the files will be read from or written into
#'
#' @author Ruben Perez Perez
#'
#' @import ggplot2
#'
#' @return Returns a barplot.
#'
#' @export
#.........................................................
divetypes_platform <- function (path = getwd()){
if(dir.exists(paste0(path, "/divewatchr_data"))){
load('divewatchr_data/scuba_clean.RData')
}
# Plot platformTypes
ggplot(scuba_clean, aes(x = platformType, fill = paste0(region, ", " ,country))) +
geom_bar(alpha = 0.7, position = "dodge2") +
ggtitle("Platform type dives") +
labs(x = "",
fill = "Region") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
}