Search code examples
rsurvival-analysis

In R, why does the length() and nrow() functions return different values on the Surv object?


I have this Surv object called y1. When I call the length() and nrow() function on it, I get different values. By inspection, y1 seems to have the number of elements that nrow() returns. Why does length() not work?

y1 <- Surv(time = inputTime, event = inputEvent, type = "right")

Solution

  • Since this Surv object has two columns, length() would give the total number of cells.

    Answer courtesy by joran.