Normally you would set the attribute of an object as
attributes(x) <- list(dummy = 123)
But I have the variable names stored in a character vector. The following code throws an error:
var <- "x"
attributes(eval(as.name(var))) <- list(dummy = 123)
Error in attributes(eval(as.name(var))) <- list(dummy = 123) : could not find function "eval<-"
If eval(as.name()) is not the right way could someone suggest a way to solve this problem?
class(eval(as.name(var)))ischaracter, whereas argument toattribute(...)should be an object, not a character