Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check that 'survfit' object was created with estimate_KM() #373

Closed
ddsjoberg opened this issue May 8, 2022 · 0 comments · Fixed by #389
Closed

Add check that 'survfit' object was created with estimate_KM() #373

ddsjoberg opened this issue May 8, 2022 · 0 comments · Fixed by #389
Assignees
Labels
issue Used for project filtering
Milestone

Comments

@ddsjoberg
Copy link
Collaborator

When a survfit object is created with estimate_KM() additional information is added to the output object. But we still return the object as class 'survift'. The consequences of this is that users could create survfit objects with survival::survfit(); they could pass this object to any visR S3 method for survfit objects, but there is a good chance there is an error.

I suggest one of the following:

  1. Add the class c("visr_survfit", "survfit") to objects created with estimate_KM() and updated all S3 methods from get_pvalue.survfit() to get_pvalue.visr_survfit(), for example. This solution is the most in-line with how most users would expect a function to work, I think.
  2. Write a simple internal function that checks if the survift object was created with visR and print a warning if it was not. Example below
is_visr_survfit <- function(x) {
  rlang::is_quosure(x$call)
}

visR::estimate_KM(visR::adtte, strata = "TRTA") |> 
  is_visr_survfit()
#> [1] TRUE

survival::survfit(survival::Surv(AVAL, 1 - CNSR) ~ TRTA, visR::adtte) |> 
  is_visr_survfit()
#> [1] FALSE

Created on 2022-05-08 by the reprex package (v2.0.1)

I don't think this is a priority and can wait until after the next CRAN release.

@ddsjoberg ddsjoberg added the issue Used for project filtering label May 8, 2022
@SHAESEN2 SHAESEN2 added this to the v0.3.0 milestone May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue Used for project filtering
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants