[R] <-

Damon Wischik djw1005 at cam.ac.uk
Wed May 14 13:19:39 CEST 2003

Uwe Ligges wrote:
> Perl experts might do it differently, but the "R way" seems to be
>   substring(x, 1, 1) <- toupper(substring(x, 1, 1))
>   substring(x, 2) <- tolower(substring(x, 2))

I hadn't come across this use of substring on the left hand side of <-
before. Now, of course, I see it explained on the help page for substr.

What other special functions can appear on the left hand side of <-? Is
there anywhere I can look to find a list? I've come across
  vector[vector of logicals] <- 
  vector[vector of integers] <- 
  data.frame[] <-

One thing I would find very handy is a shortcut for
  res <- myfunc()
  a <- res$val1
  b <- res$val2
Something along the lines of
  list(a=val1,b=val2) <- myfunc()
but I don't know what the right syntax would be or how I'd go about
programming it. Any suggestions?

Damon Wischik.

More information about the R-help mailing list