Closed ThomasSoeiro closed 5 months ago
It is documented ?survfit.object
:
Survfit objects can be subscripted. This is often used to plot a subset of the curves, for instance. From the user's point of view the
survfit
object appears to be a vector, matrix, or array of curves. The first dimension is always the underlying number of curves or “strata”; for multi-state models the state is always the last dimension. Predicted curves from a Cox model can have a second dimension which is the number of different covariate prediction vectors.
So the only question is whether it is relevant to edit the error message in [.survfit
.
If yes, I can propose a patch. If no, feel free to close without further comments.
Thanks!
Although each curve is a complex object, it is useful to think of the result of survfit as a vector, matrix or array of curves. This makes it easy to print or plot a subset of them. It is a trick, yes, but useful for the user. Also see dim(fit).
Hello,
I expected that
survfit(*)[1:2]
would return the same asunclass(survfit(*))[1:2]
. Eventually, I understood that the[.survfit
method works on indexes/names of the strata (i.e. the RHS of the formula passed tosurvfit()
) and not on indexes/names of the list returned bysurvfit()
.So maybe we could:
[.survfit
expects indexes/names of the strata in the error message: https://github.com/therneau/survival/blob/88a2b4a87661d2672e84c89e805c24e16e8826dd/R/survfit.R#L288-L291I can propose a patch if you are interested.
Thanks a lot for your work on survival!