Created
April 7, 2020 07:02
-
-
Save y9c/c43fd601f2ab41f80f05462178f1192e to your computer and use it in GitHub Desktop.
Quasiquotation of R is terrible.
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
#!/usr/bin/env Rscript | |
# -*- coding: utf-8 -*- | |
# | |
# Copyright © 2020 Ye Chang <[email protected]> | |
# Distributed under terms of the MIT license. | |
# | |
# Created: 2020-04-07 14:27 | |
f <- function(x) { | |
print(x) | |
} | |
rev_f <- function(x) { | |
if (is.name(substitute(x))) { | |
print(as.character(substitute(x))) | |
} else { | |
print(eval(as.name(x), envir = .GlobalEnv)) | |
} | |
} | |
x <- "hello" | |
f(x) | |
f("x") | |
rev_f(x) | |
rev_f("x") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment