From ff2892e1e0d1795dc07ba5e8413a08189b3b296f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sat, 24 Sep 2022 09:40:30 +0200 Subject: [PATCH] DO NOT MERGE: Hijack $ so that it can become super-fast --- NAMESPACE | 1 + R/dollar.R | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 R/dollar.R diff --git a/NAMESPACE b/NAMESPACE index baf27afad..7b0e19dab 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,6 +24,7 @@ S3method(quote_n,default) S3method(str,tbl_df) S3method(tbl_sum,tbl_df) S3method(vec_ptype_abbr,tbl_df) +export("$") export("%>%") export(add_case) export(add_column) diff --git a/R/dollar.R b/R/dollar.R new file mode 100644 index 000000000..55e7fbda4 --- /dev/null +++ b/R/dollar.R @@ -0,0 +1,7 @@ +#' @export +`$` <- function(x, name) { + env <- new_environment(list(x = x, name = as.character(substitute(name))), parent = base_env()) + call <- call2("$", x, substitute(name)) + return(eval(call, env)) + UseMethod("$") +}