R/VisualizationCount.R

Defines functions narccapCOUNT

Documented in narccapCOUNT

#' Plot a comparison count of data observations
#'
#' narccapCount function generates a graph
#' that compares the number of global points
#' with the number of regional points
#'

#' @keywords Visualization, Climate data
#' @export
#'
#' @param data Data frame object generated by joinRGdata function
#' @param year A year of the dataset
#' @param month Number of the month
#' @import dplyr stringr  ncdf4 lubridate reshape2 sp ggmap ggplot2
#'
#' @examples
#'
#' ###Not run
#' joinRGdata(globaldata, regionaldata)
#' narccapCOUNT(JoinnedDF, 1976, 11)
#'


narccapCOUNT <- function(data, year, month){
  A <- colnames(data)[str_detect(colnames(data), "global")]
  B <- data %>% group_by(indicegrid, eval(as.name(A))) %>% summarise(n = n())
  G5 <-
    ggplot(data = data) + geom_histogram(aes(x = indicegrid), bins = 500, color =
                                           "#E69F00") + geom_histogram(
                                             data = B,
                                             aes(x = indicegrid),
                                             color = "#56B4E9",
                                             bins = 500
                                           ) + theme_bw() + ylab("Count") + xlab("Space Index")
  return(G5)
}
JohanFR198/NarccapRDD documentation built on Oct. 14, 2019, 10:04 p.m.