From 98aad780ca6f8e55bb2f56a29aa1d2d8db6f5a22 Mon Sep 17 00:00:00 2001 From: Conor Anderson Date: Sat, 21 Jul 2018 13:31:14 -0400 Subject: [PATCH] Search by more than one station name. Some lint. --- DESCRIPTION | 2 +- R/station_search.R | 3 ++- man/map_stations.Rd | 14 +++++--------- man/station_search.Rd | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0c5e4f4..123b4b4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: senamhiR Type: Package Title: A Collection of Functions to Obtain Peruvian Climate Data -Version: 0.6.3 +Version: 0.6.4 Date: 2018-06-27 Authors@R: c(person(given = c("Conor", "I."), family = "Anderson", role = c("aut","cre"), email = "conor.anderson@utoronto.ca"), diff --git a/R/station_search.R b/R/station_search.R index b04813d..c2e9e55 100644 --- a/R/station_search.R +++ b/R/station_search.R @@ -2,7 +2,7 @@ ##' ##' @description Search for Senamhi stations by name, region, available data, and/or distance to a target. ##' -##' @param name character; optional character string to filter results by station name. +##' @param name character; optional character vector to filter results by station name. ##' @param ignore.case logical; by default the search for station names is not case-sensitive. ##' @param glob logical; whether to allow regular expressions in the \code{name}. See \code{\link{glob2rx}}. ##' @param region character; optional character string to filter results by region. @@ -54,6 +54,7 @@ station_search <- function(name = NULL, ignore.case = TRUE, glob = FALSE, region # If `name` is not NULL, filter by name if (!is.null(name)) { if (glob) name <- glob2rx(name) + if (length(name) > 1) name <- paste(name, collapse = "|") filt <- filter(filt, grepl(name, Station, ignore.case = ignore.case, ...)) } diff --git a/man/map_stations.Rd b/man/map_stations.Rd index 733a622..72ded06 100644 --- a/man/map_stations.Rd +++ b/man/map_stations.Rd @@ -4,25 +4,21 @@ \alias{map_stations} \title{Map Senamhi stations on an interactive map} \usage{ -map_stations(station, zoom, type = "osm") +map_stations(station, type = "osm") } \arguments{ \item{station}{character; one or more station id numbers to show on the map.} -\item{zoom}{numeric; the level to zoom the map to.} - \item{type}{character; either "osm" for OpenStreetMap tiles, or "sentinel" for cloudless satellite by EOX IT Services GmbH (\url{https://s2maps.eu}).} } \description{ Show the stations of interest on an interactive map using Leaflet. Zoom levels are guessed based on an RStudio plot window. } \examples{ -# Make a map of all the stations. -\dontrun{map_stations(catalogue$StationID, zoom = 4)} -# Make a map of all stations in Cusco. -\dontrun{map_stations(catalogue$StationID[catalogue$Region == "CUSCO"])} -##' # Make a map from station search results. -\dontrun{map_stations(station_search(region = "SAN MARTIN", baseline = 1981:2010))} +# Map a single station +map_stations(401) +# Make a map from station search results. +map_stations(station_search(region = "SAN MARTIN", baseline = 1981:2010)) } \author{ Conor I. Anderson diff --git a/man/station_search.Rd b/man/station_search.Rd index 9d298b5..bff97ef 100644 --- a/man/station_search.Rd +++ b/man/station_search.Rd @@ -9,7 +9,7 @@ station_search(name = NULL, ignore.case = TRUE, glob = FALSE, dist = 0:100, sort = TRUE, ...) } \arguments{ -\item{name}{character; optional character string to filter results by station name.} +\item{name}{character; optional character vector to filter results by station name.} \item{ignore.case}{logical; by default the search for station names is not case-sensitive.}