0
return_sum_diff <- function(a,b){return(list(a+b,a-b))}
list[t1,t2] = return_sum_diff(1,2)

It fails with the error

Error in list[t1, t2] <- return_sum_diff(2, 2) : object 't1' not found

I was trying to implement the solution here for returning multiple arguments.

Community
  • 1
  • 1
dineshdileep
  • 715
  • 2
  • 13
  • 24

1 Answers1

1

I guess in R you cant assign like that. just assign like a <- return_sum_diff(1,2) Here a will be a list with two values.

If u want a named list, modify function as follows

return_sum_diff <- function(a,b){return(list(t1 = a+b, t2 = a-b))}
Koundy
  • 5,265
  • 3
  • 24
  • 37