Skip to content

Instantly share code, notes, and snippets.

@ateucher
Last active December 18, 2019 19:46
Show Gist options
  • Save ateucher/5f0fef5e36bf516b48efa7b50133c1a7 to your computer and use it in GitHub Desktop.
Save ateucher/5f0fef5e36bf516b48efa7b50133c1a7 to your computer and use it in GitHub Desktop.
locations <- data.frame(id = "E309447")

library(rems)
library(dplyr)

hist_db <- attach_historic_data()
filtered_historic <- hist_db %>% 
  filter(EMS_ID %in% locations$id) %>% 
  collect()
#> Error: Cannot embed a data frame in a SQL query.
#> 
#> If you are seeing this error in code that used to work, the most likely
#> cause is a change dbplyr 1.4.0. Previously `df$x` or `df[[y]]` implied
#> that `df` was a local variable, but now you must make that explict with
#> `!!` or `local()`, e.g., `!!df$x` or `local(df[["y"]))

filtered_historic <- hist_db %>% 
  filter(EMS_ID %in% !!locations$id) %>% # Add the !! as directed by the error message
  collect()
  
# OR local()
filtered_historic <- hist_db %>% 
  filter(EMS_ID %in% local(locations$id)) %>% 
  collect()

Created on 2019-12-18 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment