Skip to content
Prev 199432 / 398503 Next

Survival Plot in R 2.10.0

On Nov 6, 2009, at 1:16 PM, mah wrote:

            
plot.survfit() does not support a 'type' argument.

Internally in plot.survfit(), plot() is called explicitly with 'type =  
'n' along with a '...' argument. When you try to call plot.survfit()  
with an explicit "type = 'p'" argument, it is passed to plot() as one  
of the '...' arguments. This means that internally plot() is called  
with two 'type' arguments, hence the error you get above. It would be  
like calling:

 > plot(1, 1, type = 'n', type = 'p')
Error in plot.default(1, 1, type = "n", type = "p") :
   formal argument "type" matched by multiple actual arguments


I have not used it in this particular manner, but you might want to  
look at using ?lines.survfit to add the survival model lines on an  
existing plot. An alternative to grid() is just to use abline(), which  
can draw horizontal and vertical lines at given x and y values and is  
what is used internally in grid(). See ?abline and also review ?par  
and take note of 'lty' and 'lwd', which define the line types and  
widths. Although, I was able to use grid() after your last plot() call  
above drawing points, so perhaps I am missing something:

plot(log(leukemia.surv$time), log(-log(leukemia.surv$surv)), type = "p")
grid()


HTH,

Marc Schwartz