[R] list assignment syntax?

ivo welch ivowel at gmail.com
Sat Mar 31 00:40:35 CEST 2012


Dear R wizards:  is there a clean way to assign to elements in a list?
 what I would like to do, in pseudo R+perl notation is

 f <- function(a,b) list(a+b,a-b)
 (c,d) <- f(1,2)

and have c be assigned 1+2 and d be assigned 1-2.  right now, I use the clunky

  x <- f(1,2)
  c <- x[[1]]
  d <- x[[2]]
  rm(x)

which seems awful.  is there a nicer syntax?

regards, /iaw
----
Ivo Welch (ivo.welch at brown.edu, ivo.welch at gmail.com)



More information about the R-help mailing list