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

as_ped: status variable can not be of type factor #220

Open
jonas-schropp opened this issue May 6, 2022 · 0 comments
Open

as_ped: status variable can not be of type factor #220

jonas-schropp opened this issue May 6, 2022 · 0 comments

Comments

@jonas-schropp
Copy link

When I try to use a factor variable for the status in as_ped, the code errors out. I tested this only with competing risk data where using factor or character variables for the status can make the data easier to understand.

While I think this makes some sense (eg to avoid considering the wrong factor level as censoring), the error message is not especially clear and it is somewhat unexpected because the survival package allows for factors (and I guess this is the package most users are familiar with).

Below is an example:

library(pammtools)

dat <- data.frame(
  status_fct = factor(c(0, 0, 0, 0, 1, 1, 1, 2, 2, 2)),
  time = seq(from = 10, to = 100, by = 10)
)

ped_dat <- as_ped(
  data = dat,
  formula = Surv(time, status_fct) ~ group
)

and this is the result:

Error in if (!any(1L * (unique(data[[outcome_vars[length(outcome_vars)]]])) ==  : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In Ops.factor(1L, (unique(data[[outcome_vars[length(outcome_vars)]]]))) :
  ‘*’ not meaningful for factors

I think a more helpful error message would already improve the situation, but maybe adding the functionality would make it more intuitive to use.

@jonas-schropp jonas-schropp changed the title as_ped: status variable can not be of type factor as_ped: status variable can not be of type factor May 6, 2022
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

1 participant