From ripley at stats.ox.ac.uk  Tue Oct 11 19:27:14 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 11 Oct 2005 18:27:14 +0100 (BST)
Subject: [Rd] summary of Surv object  crashes R 2.2.0 (PR#8203)
In-Reply-To: <20051011094125.3A9511C81B@slim.kubism.ku.dk>
References: <20051011094125.3A9511C81B@slim.kubism.ku.dk>
Message-ID: <Pine.LNX.4.61.0510111803360.24727@gannet.stats>

This hasn't crashed R.  It is almost certainly stack overflow due to 
excessive recursion (which is what happens on Linux, and in R-patched on 
Windows).  (Note to people tempted to raise the evaluation limit in R: 
please check against the stack size.  We've raised the latter to 10Mb on 
Windows to compensate.)  I get

> summary(surv)
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

The issue is that surv is a matrix, and summary.matrix calls 
summary.data.frame which calls summary.matrix on the matrix column ....
And this happens because there is an as.data.frame method for class Surv.
You probably got a useful error message in 2.1.0: I did.

The current code come from

r33884 | maechler | 2005-04-11 11:37:04 +0100 (Mon, 11 Apr 2005) | 1 line

summary(data.frame(I(<matrix>)))

which is clearly not enough.  When Martin gets back perhaps he can remind 
us why unclass() was not good enough here.  I think we need

> summary.matrix
function (object, ...)
summary.data.frame(data.frame(unclass(object)), ...)

since there is no other way to guarantee that data.frame splits the matrix 
up into columns.  But a summary.Surv method would be a good idea.


On Tue, 11 Oct 2005 v.moreno at ico.scs.es wrote:

> Full_Name: Victor Moreno
> Version: 2.2.0
> OS: windows
> Submission from: (NULL) (213.151.99.160)
>
>
> summary of an object class Surv (package survival) hangs and closes R 2.2.0
>
> I would like to have Surv objects in a data frame to build models easier:
>
> t<-rexp(100)
> s<-rbinom(100,1,.3)
> surv<-Surv(t,s)
> x1<-rnorm(100,10,2)
> x2<-rnorm(100,10,2)
> dat<-data.frame(surv,x1,x2)
> coxph(surv~.,data=dat)
>
> so far no problems, but R crashes if I write
>
> summary(dat)
>
> I checked that the problem is in
> summary(surv)
>
> Tested on previous versions of R (1.9.0, 2.1.0) in a friend's computer) 
> gives no results, but doesn't crash R

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] summary of Surv object crashes R 2.2.0 (PR#8203)
Prof Brian Ripley