Skip to content
Prev 61456 / 63424 Next

Multiple Assignment built into the R Interpreter?

The gsubfn package can do that.

    library(gsubfn)

    # swap a and b without explicitly creating a temporary
     a <- 1; b <- 2
     list[a,b] <- list(b,a)

     # get eigenvectors and eigenvalues
     list[eval, evec] <- eigen(cbind(1,1:3,3:1))

     # get today's month, day, year
     require(chron)
     list[Month, Day, Year] <- month.day.year(unclass(Sys.Date()))

     # get first two components of linear model ignoring rest
     list[Coef, Resid] <- lm(rnorm(10) ~ seq(10))

     # assign Green and Blue (but not Red) components
     list[,Green,Blue]  <- col2rgb("aquamarine")

     # Assign QR and QRaux but not other components
     list[QR,,QRaux]  <- qr(c(1,1:3,3:1))


On Sat, Mar 11, 2023 at 7:47?AM Sebastian Martin Krantz
<sebastian.krantz at graduateinstitute.ch> wrote:

  
    

Thread (22 messages)

Sebastian Martin Krantz Multiple Assignment built into the R Interpreter? Mar 11 Duncan Murdoch Multiple Assignment built into the R Interpreter? Mar 11 Sebastian Martin Krantz Multiple Assignment built into the R Interpreter? Mar 11 Duncan Murdoch Multiple Assignment built into the R Interpreter? Mar 11 Ivan Krylov Multiple Assignment built into the R Interpreter? Mar 11 Duncan Murdoch Multiple Assignment built into the R Interpreter? Mar 11 Sebastian Martin Krantz Multiple Assignment built into the R Interpreter? Mar 11 Duncan Murdoch Multiple Assignment built into the R Interpreter? Mar 11 Duncan Murdoch Multiple Assignment built into the R Interpreter? Mar 11 Gabriel Becker Multiple Assignment built into the R Interpreter? Mar 11 Kevin Ushey Multiple Assignment built into the R Interpreter? Mar 11 @vi@e@gross m@iii@g oii gm@ii@com Multiple Assignment built into the R Interpreter? Mar 11 Sebastian Martin Krantz Multiple Assignment built into the R Interpreter? Mar 11 Duncan Murdoch Multiple Assignment built into the R Interpreter? Mar 12 Sebastian Martin Krantz Multiple Assignment built into the R Interpreter? Mar 12 Duncan Murdoch Multiple Assignment built into the R Interpreter? Mar 12 Sebastian Martin Krantz Multiple Assignment built into the R Interpreter? Mar 12 Pavel Krivitsky Multiple Assignment built into the R Interpreter? Mar 12 Duncan Murdoch Multiple Assignment built into the R Interpreter? Mar 13 Gabor Grothendieck Multiple Assignment built into the R Interpreter? Mar 13 Martin Maechler Multiple Assignment built into the R Interpreter? Mar 14 Duncan Murdoch Multiple Assignment built into the R Interpreter? Mar 14