Skip to content
Prev 275177 / 398506 Next

setMethod "[" - extract by names within Slot

On 10/22/2011 02:11 AM, Omphalodes Verna wrote:
thinking about your code, this is the same as

 >   ID.c = c("A","A","B","B")
 >   j = "A"
 >   ID.c[j]
[1] NA
Maybe (untested)

   setMethod("[", c("myClass", "ANY", "character"),
       function(x, i, j, ..., drop=TRUE) {
           j = match(j, x at ID.c)
           x[i, j, ..., drop=TRUE]
      })