0

I'm trying to make a survival curve with the use of ggsurvplot. I've tried making a separate fit where the formula is invalid, putting the survfit formula directly into ggplot, and finally got a out a figure using a model as a fit, but even this comes out wrong.

I have three different doses in my dataset I want to compare, a control and 2 treatments. I also have different generations I wish to add, but for now I simply want to have a functioning code before putting in more complexity.

When trying to make a fit:

fit <- survfit(formula = (Surv(time=Age) ~ Dose),data=LongL1)

ggsurvplot(fit,data=LongL1)

Received error:

Error in formula.default(object, env = baseenv()) : invalid formula

Inserting model into fit:

ModLong1 <- coxph(Surv(time=Age) ~ Dose,data=LongL1)

fit <- survfit(ModLong1,data=LongL1)

ggsurvplot(fit,data=LongL1)

The curve created comes out as a combined graph rather than three separate. How do I fix this?1

Nate
  • 1
  • I'm new here and not sure how to insert data set - advise to do so properly would be appreciated! – Nate Jul 14 '22 at 09:55
  • Check the online doc for the coirrect syntax for creating a `Surv` object. – Limey Jul 14 '22 at 12:21
  • I managed to make it work with a different function - autoplot - and also fixed the data set up a little, but unfortunately never got ggsurvplot to work – Nate Jul 15 '22 at 09:05

0 Answers0