I'm trying to use a few functions of an R library called "causaldrf". Let's say, inside the library, we have a function "func(a,b)" that takes a string "a" and calls a column named "a" in a dataframe "b".
The function is implemented like this (simplified):
func(a,b){
tempcall <- match.call()
Operation then performed on tempcall, for example:
my_string <- tempcall$a
}
Turns out, the match.call() function does not evaluate the values of "a" and "b" and rather, takes them as names. I find this very annoying because when I write a for loop that reads the value of "a" from a list and call the function "func" inside the for loop, the value of "a" is not used in "func" and rather, tempcall includes unevaluated names. This makes the for loop unusable.
I'm wondering, is there a way than can make the match.call() evaluate rather than just pass the names?
One solution was to write a wrapper for func() in which I first make a string of func() and its arguments, like, "func(a,b)" and then parse it by parse("func(a,b)") and then evaluate it by eval(parse("func(a,b)")). This way, I could evaluate the values of strings and ints, but the dataframe "b" was passed as a list, which messed it up. I tried passing the dataframe as dataframe by as.dataframe(b) and different types of it, but none worked.
Then, I have used parse(), deparse(), and eval() inside the library in "func" to evaluate match.call(), but none worked.
Any ideas would be appreciated.
P.S. Developers, please don't use match.call() to check for your inputs, it hinders automation.