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

Feature request: Non-syntactic names in survfit2 objects #162

Closed
mattsecrest opened this issue Aug 28, 2023 · 3 comments
Closed

Feature request: Non-syntactic names in survfit2 objects #162

mattsecrest opened this issue Aug 28, 2023 · 3 comments

Comments

@mattsecrest
Copy link
Collaborator

I always wished survfit objects accepted non-syntactic names. Maybe something worth adding to survfit2?

library(ggsurvfit)
library(tibble)

df <- tibble(
  os_months = abs(rnorm(100, 12, .5)),
  os_event = rbinom(100, 1, .5),
  group = sample(c("group 1", "group 2"), 100, replace = TRUE),
  `group non-syntactic` = group
)

# This works
survfit2(
  Surv(os_months, os_event) ~ group,
  data = df
)

# This does not work
survfit2(
  Surv(os_months, os_event) ~ `group non-syntactic`,
  data = df
)

Even fixing the error message could be nice, as it is quite cryptic:

Error in `[.data.frame`(mf, ll) : undefined columns selected

@ddsjoberg
Copy link
Collaborator

ddsjoberg commented Aug 28, 2023

Hmmmm, we could say that survfit2() does accept these kinds of names. But the error you're seeing is what happens when we pass those args to survival::survfit() 😉

Are you thinking we could parse the formula looking for these names before passing to survival::survfit() and give a warning before the error message appears?

@mattsecrest
Copy link
Collaborator Author

I see. Since this is ultimately thrown by survival, let's see if we can fix it there instead: therneau/survival#232

@ddsjoberg
Copy link
Collaborator

Hey hey @mattsecrest ! I am going to go ahead and close this since it'll automatically work when survival is updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants