how to assign to the names() attribute of the value of a variable in R

Posted by Tony on Stack Overflow See other posts from Stack Overflow or by Tony
Published on 2010-05-25T19:35:58Z Indexed on 2010/05/25 19:41 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

In R, "assign('x',v)" sets the object whose name is 'x' to v. Replace 'x' by the result of applying a text function to a variable x. Then "assign" shows its worth.

Unfortunately, "assign(paste('names(','x',')',sep=''),v)" fails. So if 'x' is a variable x, I can set its value, but I can't give it names for its elements.

Can one work around this? a parse-eval trick maybe? Thanks.

© Stack Overflow or respective owner

Related posts about r

    Related posts about attribute