r - Why doesn't this returning of multiple values of work? -
return_sum_diff <- function(a,b){return(list(a+b,a-b))} list[t1,t2] = return_sum_diff(1,2)
it fails error
error in list[t1, t2] <- return_sum_diff(2, 2) : object 't1' not found
i trying implement solution here returning multiple arguments.
i guess in r cant assign that. assign a <- return_sum_diff(1,2)
here list 2 values.
if u want named list, modify function follows
return_sum_diff <- function(a,b){return(list(t1 = a+b, t2 = a-b))}