0

Consider the following R code:

A = 1
B = 6
Fun2 <- function(v1, v2) Fun1(v1, v2)
Fun1 <- function(d, e)   print(match.call())
Fun2(A, B)

Now the result is:

Fun2(A, B)
## Fun1(d = v1, e = v2)

Is it possible from inside Fun1 to get either a whole call to Fun2 or just variable names, that were passed to Fun2. I imagine, that the result should look like print(match.call()) was inside Fun2:

Fun2(A, B)
## Fun2(v1 = A, v2 = B)
GegznaV
  • 4,938
  • 4
  • 23
  • 43
  • Possibly related to http://stackoverflow.com/questions/15595478/how-to-get-the-name-of-the-calling-function-inside-the-called-routine/15621405#15621405 – r2evans Mar 02 '16 at 02:39
  • If you just want the variable names, try `Fun1 <- function(d, e) as.list(sys.call(1))[-1]` – MrFlick Mar 02 '16 at 02:41
  • I found out, that what I really needed was `print(match.call(definition = sys.function(sys.parent(2)), call = sys.call(sys.parent(2))))`. Thank you for getting me on a right way :) – GegznaV Mar 02 '16 at 13:15

0 Answers0