[Rd] "$<-" fails (invalid subscript type 'language')
Vitalie S.
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[[1]], "sdfdsfdsfsd")
> Error: invalid subscript type 'language'
>
>> tl$`tv[[1]]` <- "sdfdsfdsfsd"
>> tl
> [[1]]
> [1] 232
>
> $`tv[[1]]`
> [1] "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[[1]])), 4343)))
>>
>> or similar constructs using substitute().
>>
>> However, the whole situation suggests that you are really looking for
>> methods for "[[<-".
Yap, I see now, `tv[[1]]` 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
mailing list