Skip to content

Commit

Permalink
fix #340 fix meteo_nearby_stations to handle tibble input a well as d…
Browse files Browse the repository at this point in the history
…ata.frame, bump ver
  • Loading branch information
sckott committed Dec 30, 2019
1 parent c4b0154 commit 1d84dd1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: Client for many 'NOAA' data sources including the 'NCDC' climate
for 'NOAA' sea ice data, the 'NOAA' severe weather inventory, 'NOAA' Historical
Observing 'Metadata' Repository ('HOMR') data, 'NOAA' storm data via 'IBTrACS',
tornado data via the 'NOAA' storm prediction center, and more.
Version: 0.9.5.9310
Version: 0.9.5.94
License: MIT + file LICENSE
Encoding: UTF-8
Language: en-US
Expand Down
8 changes: 4 additions & 4 deletions R/meteo_distance.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#' a unique identifier for each location (`id`). For an example of the
#' proper format for this dataframe, see the examples below. Latitude and
#' longitude must both be in units of decimal degrees. Southern latitudes
#' and Western longitudes should be given as negative values.
#' and Western longitudes should be given as negative values. A tibble
#' is accepted, but is coerced to a data.frame internally before any usage.
#' @param lat_colname A character string giving the name of the latitude column
#' in the `lat_lon_df` dataframe.
#' @param lon_colname A character string giving the name of the longitude column
Expand Down Expand Up @@ -103,15 +104,14 @@ meteo_nearby_stations <- function(lat_lon_df, lat_colname = "latitude",
var = "all", year_min = NULL,
year_max = NULL, radius = NULL,
limit = NULL){
var <- tolower(var)

lat_lon_df <- as.data.frame(lat_lon_df)
var <- tolower(var)
# Ensure `id` in `lat_lon_df` is character, not factor
lat_lon_df$id <- as.character(lat_lon_df$id)

# Ensure lat/long are numeric
lat_lon_df[, lat_colname] <- as.numeric(as.character(lat_lon_df[, lat_colname]))
lat_lon_df[, lon_colname] <- as.numeric(as.character(lat_lon_df[, lon_colname]))

# Handle generic values for `var`, `year_min`, and `year_max` arguments
if (is.null(year_min)) year_min <- min(station_data$first_year, na.rm = TRUE)
if (is.null(year_max)) year_max <- max(station_data$last_year, na.rm = TRUE)
Expand Down
3 changes: 2 additions & 1 deletion man/meteo_nearby_stations.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1d84dd1

Please sign in to comment.