s-news
[Top] [All Lists]

extraction method question

To: s-news@lists.biostat.wustl.edu
Subject: extraction method question
From: Joe Cerniglia <cj5815@yahoo.com>
Date: Mon, 6 Jun 2005 07:30:06 -0700 (PDT)
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=B3+y+X/ENpIhBRuri2HncgYgcVG3F1SDirn/iydNsixAwEIUqVGubkDKNNEp86MZ9014KGKqmF3fAcJ+t/8cX/ei5aghpcvA0i5usZ7KfImCROpFixWKcnyQU8temJR/qLew7b39bzCldxYuILHXC8B1bkLIjm59/bbtl1FvU0U= ;
I extended the time series class to form a new class
called data.analysis class.  I would like a
extraction method on this new class to be well
defined.  I am getting an error message when I run
this method.  I also include the code for my new
class.

Thanks.

Joe


setMethod("[", "data.analysis" ,function(x, ..., drop
= T)
        # drop argument is ignored when subscripting time
series!
        ndots <- nDotArgs(...)
        if(ndots < 1)
                return(x)
        args <- match.call(function(x, i, j, drop)
        {
        }
        )
        if(!is.null(args$i)) {
                i <- eval(args$i, sys.parent(1))
                if(is.null(i))
                        i <- 0
        }
        else i <- NULL
                
        if(!is.null(args$j)) {
                j <- eval(args$j, sys.parent(1))
                if(is.null(j))
                        j <- 0
        }
        else j <- NULL
                
        # if i,j args are time series, convert them
        if(is(i, "series")) i <- seriesData(i)
        if(is(j, "series"))     j <- seriesData(j)
        if(!is.null(i)) x@positions <- x@positions[i]
                
        oldnames <- colIds(x@data)
        names(oldnames) <- oldnames

        if(!is.null(i) && !is.null(j))
                x@data <- asSeriesData(sub(x@data, i, j))
        else if(is.null(i) && !is.null(j))
                x@data <- asSeriesData(sub(x@data,  , j))
        else if(!is.null(i) && is.null(j))
                x@data <- asSeriesData(sub(x@data, i,  ))

        if(!is.null(j))
                newnames <- oldnames[j]
        else newnames <- oldnames

        names(newnames) <- NULL

        nc <- numCols(x@data)

        # may have ended up with a null data matrix here
        if(!is.data.frame(x@data) && !is.null(newnames))
rowIds(x@data) <- character(0)
        if(nc && !is.null(newnames))
                colIds(x@data) <- newnames[1:nc]
        x
)

#############################################3
new class to use the extraction method
setClass("data.analysis", representation=
representation("series",factors= "character"),
         prototype = list("data" = matrix(NULL, nrow = 0,
ncol = 1)
        , "positions" = NULL
        , "start.position" = NULL
        , "end.position" = NULL
        , "future.positions" = NULL
        , "units" = character(0)
        , "title" = character(0)
        , "documentation" = character(0)
        , "attributes" = NULL
        , contains = list("seriesVirtual" = numeric(0))
                        ) )



                
__________________________________ 
Yahoo! Mail 
Stay connected, organized, and protected. Take the tour: 
http://tour.mail.yahoo.com/mailtour.html 


<Prev in Thread] Current Thread [Next in Thread>
  • extraction method question, Joe Cerniglia <=