R/geographic_average.R

Defines functions geographic_average

Documented in geographic_average

#' Calculates median latitudes and longitudes based on input
#' @export

geographic_average <- function(lat, lng, weight = NULL){
  if (is.null(weight)) {
    weight <- rep(1, length(lng))
  }
  mean_lat <- weighted.mean(lat, w = weight)
  mean_lng <- weighted.mean(lng, w = weight)
  list(lat = mean_lat, lng = mean_lng)
}
BrianAronson/docshop documentation built on Jan. 13, 2020, 3:13 a.m.