I would like to extract the name of a function parameter as a string.
It works fine unless the function is called from within another function (see below).
There must be a simple solution for this, just cannot seem to find one.
library(reprex)
print_data_1 <- function(DATA) {
DATA_txt <- deparse(substitute(DATA))
print(DATA_txt)
}
print_data_2 <- function(DF) {
print_data_1(DF)
}
print_data_1(mi_d)
#> [1] "mi_d"
print_data_2(mi_d)
#> [1] "DF"
print_data_2
should return "mi_d".
Created on 2021-05-14 by the reprex package (v2.0.0)