Skip to content

Commit

Permalink
fix #375 dplyr filter_/select_/distinct_ to versions without underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Nov 16, 2020
1 parent 5ae5625 commit cc4d358
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 8 additions & 5 deletions R/meteo_distance.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,14 @@ meteo_nearby_stations <- function(lat_lon_df, lat_colname = "latitude",
if (is.null(year_max)) year_max <- max(station_data$last_year, na.rm = TRUE)
if (length(var) == 1 && var == "all") var <- unique(station_data$element)

dots <- list(~last_year >= year_min & first_year <= year_max &
element %in% toupper(var) & !is.na(element))
station_data <- dplyr::filter_(station_data, .dots = dots) %>%
dplyr::select_(~id, ~name, ~latitude, ~longitude) %>%
dplyr::distinct_()
station_data <- dplyr::filter(station_data,
last_year >= year_min &
first_year <= year_max &
element %in% toupper(var) &
!is.na(element)
) %>%
dplyr::select(id, name, latitude, longitude) %>%
dplyr::distinct()

location_stations <- as.data.frame(lat_lon_df) %>%
split(.[, "id"]) %>%
Expand Down
6 changes: 2 additions & 4 deletions R/meteo_utils.r
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ meteo_coverage <- function(meteo_df,
verbose=FALSE) {

if (!is.null(obs_start_date)) {
dots <- list(~as.Date(date) >= obs_start_date)
meteo_df <- dplyr::filter_(meteo_df, .dots = dots)
meteo_df <- dplyr::filter(meteo_df, date >= obs_start_date)
}

if (!is.null(obs_end_date)) {
dots <- list(~as.Date(date) <= obs_end_date)
meteo_df <- dplyr::filter_(meteo_df, .dots = dots)
meteo_df <- dplyr::filter(meteo_df, date <= obs_end_date)
}

dplyr::group_by(meteo_df, id) %>%
Expand Down

0 comments on commit cc4d358

Please sign in to comment.