[Rd] "$<-" fails (invalid subscript type 'language')
spinuvit.list at gmail.com
Mon Oct 25 14:14:18 CEST 2010
spinuvit.list at gmail.com (Vitalie S.) writes:
> I would expect the following to behave identically:
>> tv <- c(a="dsf", b="sss")
>> tl <- list(232)
>> `$<-`(tl, tv[], "sdfdsfdsfsd")
> Error: invalid subscript type 'language'
>> tl$`tv[]` <- "sdfdsfdsfsd"
>  232
>  "sdfdsfdsfsd"
> So what is relay going on? In one case the name is expected, in another case any
> "language" object would work?
>> If you insist, you can do things like
>> eval(bquote(`$<-`(x, .(as.name(tv[])), 4343)))
>> or similar constructs using substitute().
>> However, the whole situation suggests that you are really looking for
>> methods for "[[<-".
Yap, I see now, `tv[]` is a name. So no contradiction.
To conclude, only the symbol is allowed as index and I can not do absolutely
anything to make my custom "$" "smarter":(.
Thanks everyone for helping me filter some noise in my head.
More information about the R-devel