2

I want to turn the assignment into a string and have it be one of the outputs of the function.

Input:

y <- f(x)

Desired Output:

"y"

I thought maybe sys.call() would help but it doesn't seem to include the assignment.

Jaap
  • 81,064
  • 34
  • 182
  • 193
Jeffrey Girard
  • 761
  • 4
  • 20
  • This question has been asked before (https://stackoverflow.com/questions/46204937/how-do-i-access-the-name-of-the-variable-assigned-to-the-result-of-a-function-wi) but it didn't receive an answer there either. – Noah Oct 21 '18 at 17:13
  • Thanks for the link! I searched but didn't find that one. Feel free to close this question. – Jeffrey Girard Oct 21 '18 at 17:14
  • 1
    Well this is an interesting question that still hasn't been answered so I think it's worth keeping. – Noah Oct 21 '18 at 17:15
  • 1
    Would it be ok to change the function call to `f(y, x)` ? In that case f <- `function(y, x) list(y = deparse(substitute(y)), x = x)` so to test it `f(zz, 3)` – G. Grothendieck Oct 21 '18 at 17:35

0 Answers0