,
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
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
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
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)
}
4 matches
Mail list logo