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

ggflexsurvplot removing groups from KM plot #408

Open
andersbergren opened this issue Jul 10, 2019 · 5 comments
Open

ggflexsurvplot removing groups from KM plot #408

andersbergren opened this issue Jul 10, 2019 · 5 comments

Comments

@andersbergren
Copy link

ggflexsurvplot() should show the KM curve with model fit curves for all strata. Instead the strata for the KM curve have been relabelled "All".

May be related to the length(summary(fit)) check that should only relabel strata to "All" if if the summary list length equals 1.

Here you can see my model fit curves and and the broken red "All" KM curve which should be broken out by strata.

image

@andersbergren
Copy link
Author

Seems related to this code in the function:
isfac <- .is_all_covariate_factor(fit) if(!all(isfac)){ .formula <- .build_formula(surv.obj, "1") n.strata <- 1 }
It creates a vector that's not a factor, then checks if that vector is a factor. Always returning false I believe.

@andersbergren
Copy link
Author

Result when check is removed
image

@kassambara
Copy link
Owner

ggflexsurvplot() expected the grouping variable to be strictly a factor for showing grouped KM.

fixes: now, the grouping variable can be either a factor or a character vector (in your example).

Should work now, thanks!

You can install the latest dev version as follow:

devtools::install_github("kassambara/survminer", build_vignettes = FALSE, dependencies = FALSE)

@jumbanhounc
Copy link

I'm still getting this problem. I think the problem is in the function is_factor_or_character has:
'is.facet(x) | is.character(x) and should be 'is.factor(x) | is.character(x)

@igutermes
Copy link

The issue sting lingers.

Just in case anyone is still stuck in this problem, just use a as.character() in your model and the function will work as expected.

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

4 participants