Skip to content
Prev 175445 / 398506 Next

Column name assignment problem

Steve Murray wrote:
The generic issue here (read: I can't really be bothered to do your
problem in all details...) is that you cannot use assignment forms like

foo(x) <- bar

while accessing x via a character name. That is

a <- "plugh!"
assign(foo(a), bar)

and

foo(get(a)) <- bar

are both wrong.

You need to do it in steps, like

x <- get(a)
foo(x) <- bar
assign(a, x)

or, not really any prettier

eval(substitute(
   foo(x) <- bar, list(x=as.name(a)
))