Skip to content
Prev 206721 / 398503 Next

An argument processing puzzle.

Rolf Turner wrote:
Rolf,
  are you just trying to turn the input into character?
If so, the following may help, but I'd be surprised if
there aren't plenty of situations where it won't work.
I ain't no guru.

g <- function(x){
   x <- substitute(x)
   if(is.name(x)) {
     xnm <- deparse(x)
   }
   else {
     if(is.language(x)) {
       xnm <- eval(x)
     }
     else xnm <- x
   }
   get(xnm)
}

u <- 1:5
v <- letters[1:5]
u.v <- 5:1

g(u)
g('u')
g(v)
g('v')
g(paste('u', 'v', sep='.'))

  -Peter Ehlers