Skip to content

Instantly share code, notes, and snippets.

@paulrougieux
Last active April 15, 2016 09:03
Show Gist options
  • Save paulrougieux/106145fe335790a12ed42e5eeb7ba4f0 to your computer and use it in GitHub Desktop.
Save paulrougieux/106145fe335790a12ed42e5eeb7ba4f0 to your computer and use it in GitHub Desktop.
dplyr::filter nse
library(dplyr)
library(lazyeval)
Species <- "virginica"
# The Species variable is interpreted
# in the context of the data frame
iris %>%
filter_(Species == Species) %>%
nrow()
# 150
# The Species variable is interpreted
# in the context of the global environment
iris %>%
filter_(interp(~Species == which_species,
which_species = Species)) %>%
nrow()
# 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment