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))} 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -