[R] Trying to run simple survival program in R but does not work

Duncan Murdoch murdoch at stats.uwo.ca
Thu Aug 7 14:30:24 CEST 2008


On 07/08/2008 3:56 AM, Trev101 wrote:
> Hey,
> 
> I am just starting to learn R now and I typed in this simple survival
> program:
>   
>    library(survival)
>    t <- c(10,13,18,19,23,30,36,38,54,56,59,75,93,97,104,107,107,107)
>    c <- c(1,0,0,1,0,1,1,0,0,0,1,1,1,1,0,1,0,0)
>    data <- Surv(t,c)
>    km <- survfit(data)       
>    summary(km)
>    Call: survfit(formula = data)
> 
> but everytime I run it I get this error:
>   
>   Error in eval.with.vis(expr, envir, enclos) : object "Call" not found
> 
> Can someone please help me out I really have no idea wat I have done wrong.
> I have installed the survival library is there maybe some other library I
> need to install?

The last line, "Call: survfit(formula = data)", is not R code.  It is 
the first line of the output you should expect to see, i.e.

 >  library(survival)
Loading required package: splines
 >    t <- c(10,13,18,19,23,30,36,38,54,56,59,75,93,97,104,107,107,107)
 >    c <- c(1,0,0,1,0,1,1,0,0,0,1,1,1,1,0,1,0,0)
 >    data <- Surv(t,c)
 >    km <- survfit(data)
 >    summary(km)
Call: survfit(formula = data)

  time n.risk n.event survival std.err lower 95% CI upper 95% CI
    10     18       1    0.944  0.0540        0.844        1.000
    19     15       1    0.881  0.0790        0.739        1.000
    30     13       1    0.814  0.0978        0.643        1.000
    36     12       1    0.746  0.1107        0.558        0.998
    59      8       1    0.653  0.1303        0.441        0.965
    75      7       1    0.559  0.1412        0.341        0.917
    93      6       1    0.466  0.1452        0.253        0.858
    97      5       1    0.373  0.1430        0.176        0.791
   107      3       1    0.249  0.1392        0.083        0.745

Duncan Murdoch



More information about the R-help mailing list