Skip to content

Commit

Permalink
eliminates {dplyr} dependency (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
fdetsch committed Jun 9, 2022
1 parent 370510c commit e41645e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Depends:
Imports:
rworldmap,
gmt,
dplyr,
zoo,
Rssa,
reshape2,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#### 🍬 miscellaneous

* Eliminates {dplyr} dependency (#12)


# GSODTools 1.0.5 (2022-06-08)

Expand Down
17 changes: 12 additions & 5 deletions R/stationFromCoords.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
#' gsod_shp <- stationFromCoords(x = kibo,
#' width = 100)
#'
#' @importFrom dplyr arrange
#'
#' @export
stationFromCoords <- function(x,
y = NULL,
Expand All @@ -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
Expand All @@ -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)
,
]
}
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e41645e

Please sign in to comment.