You cannot assign a value to a variable returned , see
> x <- 'cars'
> get(x) <- 1
Error in get(x) <- 1 : could not find function "get<-"
But reading / loading the comment of the returned variable is possible with get, see
> comment(cars) <- "test"
> comment(get(x))
[1] "test"
, . , :
> l <- list(a=1,b=2,c=3)
> for (x in 1:3) {
+ comment(l[[letters[x]]]) <- paste(x)
+ }
> str(l)
List of 3
$ a: atomic [1:1] 1
..- attr(*, "comment")= chr "1"
$ b: atomic [1:1] 2
..- attr(*, "comment")= chr "2"
$ c: atomic [1:1] 3
..- attr(*, "comment")= chr "3"
, , :
> attach(l)
The following object(s) are masked _by_ '.GlobalEnv':
a, b, c
> a
[1] 1
> str(a)
atomic [1:1] 1
- attr(*, "comment")= chr "1"