Re: [Rd] "$<-" fails (invalid subscript type 'language')

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Sun, 24 Oct 2010 06:34:51 -0700

On Oct 24, 2010, at 5:35 AM, Vitalie S. wrote:

>
> This might be just beyond of my understanding of how assignment
> works in R, but
> the documentation does not say anything about:
>
>> tv <- c(a="dsf", b="sss")
>> tl <- list(232)
>> `$<-`(tl, tv[[1]], "sdfdsfdsfsd")
> Error: invalid subscript type 'language'

Are either of these what you should have done to get what it appears you were aiming for but didn't specify?

  `$<-`(tl, "sdfdsfdsfsd", tv[[1]])
# yields
[[1]]
[1] 232

$sdfdsfdsfsd
[1] "dsf"

 > `[<-`(tl, tv[[1]], "sdfdsfdsfsd")
[[1]]
[1] 232

$dsf
[1] "sdfdsfdsfsd"

The "$" operator does not evaluate the index whereas the "[" function does. And the documentation is quite clear about that distinction.

-- 
David Winsemius.



>
> This happens even before the method is dispatched. I can not handle
> the
> "name" argument in my S4 method, because it's not even entered.
>
> Thanks,
> Vitalie.
______________________________________________ R-devel_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sun 24 Oct 2010 - 13:36:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 24 Oct 2010 - 20:50:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive