Created
October 27, 2018 01:44
-
-
Save cfhammill/4244e29bc667455a2406bf972e4287c6 to your computer and use it in GitHub Desktop.
Log what symbols are hit in your data with tidy_eval
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(rlang) | |
logged_eval_tidy <- | |
function(expr, data, env = caller_env()){ | |
dm <- as_data_mask(data) | |
ae <- as_data_mask(list()) | |
nms <- character(0) | |
te <- environment() | |
report_sym <- function(nm){ | |
get_sym <- function(){ | |
assign("nms" | |
, c(get("nms", envir = te), nm) | |
, envir = te) | |
get(nm, envir = dm) | |
} | |
makeActiveBinding(nm, get_sym, ae) | |
} | |
lapply(names(data), report_sym) | |
list(val = eval_tidy(expr, ae, env) | |
, nms = nms) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment