I agree that it's cleaner to remove the extra attributes -- that's the
point of as.matrix.Surv(), to produce a matrix that doesn't include any
extra details of how Surv objects are implemented.

   -thomas


On Fri, Dec 7, 2012 at 3:48 AM, Terry Therneau <thern...@mayo.edu> wrote:

> 1. A Surv object is a matrix with some extra attributes.  The
> as.matrix.Surv function removes the extras but otherwise leaves it as is.
>
> 2. The last several versions of the survival library were accidentally
> missing the S3method('as.matrix', 'Surv') line from their NAMESPACE file.
>  (Instead it's position is held by a duplicate of the line just above it in
> the NAMESPACE file, suggesting a copy/paste error).  As a consequence the
> as.matrix.Surv function was effectively ignored, and the default method was
> being used.
>    The as.matrix.default function leaves anything with a "dim" attribute
> alone.
>
> 3. In my current about-to-submit-to-CRAN  version of survival the missing
> NAMESPACE line was restored.  This breaks one function in one package (rms)
> which calls "as.matrix(y)" on a Surv object but then later looks at the
> "type" attribute of y.
>
>  So now to the design question: should the as.matrix.Surv function
> "sanitize" the result by removing the extra attributes, or should it leave
> them alone?  The first seems cleaner; my accidental multi-year test of
> leaving them in, however, clearly shows that it does no harm.
>
> Terry T.
>
> ______________________________**________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-devel<https://stat.ethz.ch/mailman/listinfo/r-devel>
>



-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to