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.
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)