Re: [R] setMethod "[" - extract by names within Slot

2011-10-23 Thread Martin Morgan
, function(x, i, j, ..., drop=TRUE) { x[i, x@cid[j], ..., drop=TRUE] }) setMethod("[", c("A", "missing", "numeric"), function(x, i, j, ..., drop=TRUE) { x[, x@cid[j], ..., drop=drop] }) Here are some tests a <- new("A", rid=1:5

Re: [R] setMethod "[" - extract by names within Slot

2011-10-22 Thread Omphalodes Verna
quot;] #works a[5:20, "B"] #works It works, but Is it normal to write two codes for setMethod??? Nice weekend, OV From: Martin Morgan Cc: "r-help@r-project.org" Sent: Saturday, October 22, 2011 3:50 PM Subject: Re: [R] setMethod &q

Re: [R] setMethod "[" - extract by names within Slot

2011-10-22 Thread Martin Morgan
On 10/22/2011 02:11 AM, Omphalodes Verna wrote: Hi R-helper! I have problem with setMethods for "[". Here is example : setClass("myClass", representation(ID.r = "numeric", ID.c = "character", DAT = "matrix")) to.myClass<- function(ID.r, ID.c, DAT) { out<- new("myClass", ID.r = ID.r, ID.c

[R] setMethod "[" - extract by names within Slot

2011-10-22 Thread Omphalodes Verna
Hi R-helper! I have problem with setMethods for "[". Here is example : setClass("myClass", representation(ID.r = "numeric", ID.c = "character", DAT = "matrix")) to.myClass <- function(ID.r, ID.c, DAT) {     out <- new("myClass", ID.r = ID.r, ID.c = ID.c, DAT = DAT)     return(out)   }