Last active
April 15, 2016 09:03
-
-
Save paulrougieux/106145fe335790a12ed42e5eeb7ba4f0 to your computer and use it in GitHub Desktop.
dplyr::filter nse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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