tidymodels / broom

Convert statistical analysis objects from R into tidy format
https://broom.tidymodels.org
Other
1.46k stars 304 forks source link

transition to survival's `nobs()` methods #1224

Closed simonpcouch closed 2 months ago

simonpcouch commented 2 months ago

On devtools::document():

Registered S3 methods overwritten by 'survival':
  method       from 
  nobs.coxph   broom
  nobs.survreg broom
simonpcouch commented 2 months ago

The definitions of nobs.survreg() are identical, so we can just remove broom's method. For coxph:

survival:::nobs.coxph
function (object, ...) 
object$nevent
<bytecode: 0x16cc8f0e0>
<environment: namespace:survival>

while in broom:

nobs.coxph
function(object, ...) {
  length(object$linear.predictors)
}
<environment: namespace:broom>

broom's definition is copied over for its nobs.survreg(), it seems.

Wooooof. With the fit objects from the tests:

for (f in list(fit, fit2, fit3, fit4, fit5, fit6)) {
  cat(paste0(survival:::nobs.coxph(f), " ", broom:::nobs.coxph(f)))
  cat("\n")
}
#> 165 228
#> 165 228
#> 164 227
#> 112 340
#> 897 1822
#> 897 1822
github-actions[bot] commented 1 month ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.