Does anyone know a way to fit the cominc function from the cmprisk package to the ggplot2 package?
I am getting this error message:
Don't know how to automatically pick scale for object of type cuminc. Defaulting to continuous - Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : kan ikke tvinge klasse »"cuminc"« ind i en data.frame
- ggplot2 doesn't know how to deal with data of class cuminc
I found a function to split the cuminc function so you can plot individual causes instead of both in the same plot:
cs.cuminc <- function(x,cause="1"){
if (!is.null(x$Tests))
x <- x[names(x) != "Tests"]
which.out <- which(unlist(strsplit(names(x), " "))[seq(2,length(names(x))*2,2)]!=cause)
x[which.out] <- NULL
class(x) <- "cuminc"
return(x)
}
This provides a plot with two curves - stil ggplot2 can't deal with the function.