[R] Survival aareg problem

Terry Therneau therneau at mayo.edu
Wed Jun 5 14:12:56 CEST 2013



On 06/05/2013 12:33 AM, r-help-request at r-project.org wrote:
> Dear friends - I'm on windows 7, R 2.15.2
>
> when I run the example for aareg in survival package I see this:
>
>    plot(lfit[4], ylim=c(-4,4))
> error in xy.coords(x, y, xlabel, ylabel, log) :
>     'x' is a list, but does not have components 'x' and 'y'
>
> Is that a matter of an old R?
>
> Best wishes
>
> Troels Ring, MD
> Aalborg, Denmark

It's an error in the survival package: the line "S3method('[', aareg)" was missing from 
the NAMESPACE file.
Without it R doesn't find the correct code to perform the subscripting.  (In earlier 
versions of R a declaration of every S3 method was not necessary.)  You are the first to 
run into this.

   This will be fixed in the next (soon) release.  In the meantime, simply read in a copy 
of the subscripting code into your session, either with source() or cut and paste.   The 
code is below.

    Terry Therneau

"[.aareg" <- function(x, ..., drop=FALSE) {
     if (!inherits(x, 'aareg')) stop ("Must be an aareg object")
     i <- ..1
     if (is.matrix(x$coefficient)) {
         x$coefficient <- x$coefficient[,i, drop=drop]
         x$tweight <- x$tweight[,i,drop=drop]
     }
     else stop("Subsripting impossible, coefficient component not a matrix")

     if (!is.null(x$dfbeta)){
         x$dfbeta <- x$dfbeta[,i,,drop=drop]
         x$test.var2 <- x$test.var2[i,i,drop=drop]
     }
     x$test.statistic <- x$test.statistic[i, drop=drop]
     x$test.var <- x$test.var[i,i,drop=drop]
     x
     }



More information about the R-help mailing list