Last active
August 19, 2020 21:14
-
-
Save TysonStanley/6fe3aefa1420b19be02d518b8f57902e to your computer and use it in GitHub Desktop.
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
``` r | |
library(tibble) | |
df = tibble( | |
var1 = rnorm(5), | |
var2 = rnorm(5) | |
) | |
first = function(data, x){ | |
x = substitute(x) | |
eval(x, data) | |
} | |
wrap = function(data, x){ | |
first(data, x) | |
} | |
wrap_working = function(data, x){ | |
eval(substitute(first(data, x))) | |
} | |
first(df, var1) | |
#> [1] 2.4489749 -0.2397701 0.7707028 0.2790378 0.4131106 | |
wrap(df, var1) | |
#> x | |
wrap_working(df, var1) | |
#> [1] 2.4489749 -0.2397701 0.7707028 0.2790378 0.4131106 | |
``` | |
<sup>Created on 2020-08-19 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0)</sup> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is an option that tries to better account for environments: