Skip to content
Prev 38123 / 63424 Next

"$<-" fails (invalid subscript type 'language')

David Winsemius <dwinsemius at comcast.net> writes:
I meant what I wrote there. After the assignment, the list tl  should have element 'dsf' with the
value "sdfdsfdsfsd" (sorry for bad names).
If it is evaluated or not it is hardly an explanation for the error. It throws
the error before the method is even dispatched. If the index (in $'s case the
name) is unevaluated then my methods should get an expression 'tv[[1]]', which I
can then handle.

Example:

setClass("classX", contains="list")
setMethod("$<-", "classX",
          function(x, name, value){
              print("I am here!!")
              x
          })

x <- new("classX")
tv <- c("aa", "bb")
`$<-`(x, tv[[1]], 4343)
#gives
Error: invalid subscript type 'language'