diff --git a/DESCRIPTION b/DESCRIPTION index 7ea6626..118cd61 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,7 +24,6 @@ Imports: lubridate (>= 1.7.1), magrittr (>= 1.5), methods (>= 3.2.2), - sp (>= 1.2-3), stringi (>= 1.1.2), tibble (>= 1.2), tidyr (>= 0.4.1), @@ -35,6 +34,7 @@ Suggests: ggplot2, knitr, rmarkdown, + sp, stringr, testthat VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index b607a3f..352123e 100755 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,12 @@ author: "Steffi LaZerte" output: html_document --- +# weathercan 0.2.3.9000 + +## Changes +- `sp` moved to suggests, users are now prompted to install sp if they want to search stations by coordinates + + # weathercan 0.2.3 (2017-11-22) ## Changes diff --git a/R/stations.R b/R/stations.R index 5b34326..ee35857 100755 --- a/R/stations.R +++ b/R/stations.R @@ -131,6 +131,9 @@ stations_all <- function(url = NULL, #' @param quiet Logical. Suppress all messages (including messages regarding #' missing data, etc.) #' +#' @details To search by coordinates, users must make sure they have the +#' \code{\link[sp]{sp}} package installed. +#' #' @return Returns a subset of the stations data frame which match the search #' parameters. If the search was by location, an extra column 'distance' shows #' the distance in kilometres from the location to the station. If no stations @@ -166,6 +169,11 @@ stations_search <- function(name = NULL, if(length(coords) != 2 | all(is.na(coords)) | class(coords) == "try-error") { stop("'coord' takes one pair of lat and lon in a numeric vector") } + + if(!requireNamespace("sp", quietly = TRUE)) { + stop("Package 'sp' required to search for stations using coordinates. Use the code \"install.packages('sp')\" to install.", call. = FALSE) + } + } check_int(interval) diff --git a/man/stations_search.Rd b/man/stations_search.Rd index ffdbb40..c2cdb87 100755 --- a/man/stations_search.Rd +++ b/man/stations_search.Rd @@ -43,6 +43,10 @@ Returns stations that match the name provided OR which are within \code{dist} km of the location provided. This is designed to provide the user with information with which to decide which station to then get weather data from. } +\details{ +To search by coordinates, users must make sure they have the + \code{\link[sp]{sp}} package installed. +} \examples{ stations_search(name = "Kamloops")