1

I'm sorry if the question looks silly, but I have a small data set which I would like to manipulate with function "survfit" of R package "survival", and, well, I don't know to set a proper dataframe usable by "survfit"; data are as follows:

      time number_at_risk number_death number_censored
    1   25             10            0               2
    2   28              8            1               0
    3   33              7            1               0
    4   37              6            0               1
    5   41              5            1               0
    6   43              4            0               1
    7   48              3            0               3

And now, if I run the usual syntax survfit(Surv(time, number_censored) ~ 1, data = data), it gives me the warning In Surv(time, number_censored) : Invalid status value, converted to NA.

Obviously, the data are not properly organized. So, how should I set my dataframe? Thanks.

Andrew
  • 926
  • 2
  • 17
  • 24

1 Answers1

2

time must be a vector with the times where an event happened and status an indicator if that event is a censorship or death (0/1).

In your example the data should look like this:

times = c(1,1,2,3,4,5,6,7,7,7)
status = c(0,0,1,1,0,1,0,0,0,0)

survfit(Surv(times,status)~1)
Fino
  • 1,774
  • 11
  • 21
  • OK, so I just had to split the lines when multiple subjects are censored at a given time. That works, thanks. – Andrew Sep 27 '19 at 19:19