R/get_hystreet_stats.R

Defines functions get_hystreet_stats

Documented in get_hystreet_stats

#' Get statistics from the Hystreet Project via Hystreet API
#'
#' @param verbose [logical] (**optional**): Show more verbose output?
#' @param API_token [character] (**optional**): API key to get access to Hystreet API
#' 
#' @return [data.frame] with parsed data from hystreet API
#'
#' @section Function version:
#'  0.0.2
#' @author Johannes Friedrich
#' 
#' @examples 
#' \dontrun{
#'  get_hystreet_stats(TRUE)
#' }
#' @md
#' @export

get_hystreet_stats <- function(verbose = FALSE, API_token = NULL){
  
  
  res <- .create_hystreet_request(API_token)
  
  if(verbose){
    
    return(res)
    
  } else {
    
    stats <- data.frame(
      stations = nrow(res),
      today_count = sum(res$statistics$today_count)
    )
   
    return(stats) 
    
  }
  
}

Try the hystReet package in your browser

Any scripts or data that you put into this service are public.

hystReet documentation built on Nov. 27, 2022, 5:05 p.m.