diff --git a/DESCRIPTION b/DESCRIPTION index 7f31f65..6467be3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,7 +10,6 @@ Depends: Imports: rworldmap, gmt, - dplyr, zoo, Rssa, reshape2, diff --git a/NAMESPACE b/NAMESPACE index 362cdc1..dec1a81 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,7 +28,6 @@ import(utils) importFrom(Rssa,nsigma) importFrom(Rssa,ssa) importFrom(TSA,harmonic) -importFrom(dplyr,arrange) importFrom(forecast,forecast) importFrom(gmt,geodist) importFrom(graphics,points) diff --git a/NEWS.md b/NEWS.md index 3da6699..fd1ed41 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,8 @@ #### 🍬 miscellaneous + * Eliminates {dplyr} dependency (#12) + # GSODTools 1.0.5 (2022-06-08) diff --git a/R/stationFromCoords.R b/R/stationFromCoords.R index 46863d0..1da8f59 100644 --- a/R/stationFromCoords.R +++ b/R/stationFromCoords.R @@ -50,8 +50,6 @@ #' gsod_shp <- stationFromCoords(x = kibo, #' width = 100) #' -#' @importFrom dplyr arrange -#' #' @export stationFromCoords <- function(x, y = NULL, @@ -69,6 +67,7 @@ stationFromCoords <- function(x, } # Calculate distance from point of interest to supplied stations + # TODO: what happens if there are 2+ points in input stations <- gsodstations x.to.stations <- gmt::geodist( Nfrom = y @@ -78,8 +77,16 @@ stationFromCoords <- function(x, # Add calculated distances to stations stations$DIST <- round(x.to.stations, ...) - # Identify and return GSOD stations that lie within the given buffer width - stations <- stations |> subset(DIST <= width) |> dplyr::arrange(DIST) |> gsodDf2Sp() + # Find stations that lie within the given buffer width and convert to spatial + stations = stations |> + subset( + DIST <= width + ) |> + gsodDf2Sp() - return(stations) + # Sort by distance and return + stations[ + order(stations$DIST) + , + ] } \ No newline at end of file diff --git a/TODO b/TODO index bb22db6..52b74a9 100644 --- a/TODO +++ b/TODO @@ -5,7 +5,7 @@ General - further details: https://roxygen2.r-lib.org/articles/markdown.html * add ci/cd * gsod --> isd -* {dplyr}, {data.table} (built-in data object) or base +* {data.table} (built-in data object) or base * re-enable (some) `\dontrun` examples * handle records in `gsodstations` with lon = lat = 0.0 * find solution for `gsodstations` duplication (internal vs. external)