how to assign to the names() attribute of the value of a variable in R
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. In the form you ask question there is no need to assign names. If you x exists then you do names(x) <- v . This is right way to do this. If your variable name is unknown (i.e. dynamically created) then you could use