Hi everyone, I am not new to R, but new to running survival models in R. I am trying to create some basic KM curves, using the following code:
library(survival) library(KMsurv) (import data etc - basic right censored, with continuously observed time of death) sleepfit <- survfit(Surv(timeb, death), data = sleep) Here timeb is measured is survival in years, death is a 1/0 indicator (1 = event = death), and the dataset is called sleep. But I get the following error Error in UseMethod("survfit", formula) : no applicable method for 'survfit' applied to an object of class "Surv" I'm not sure what I'm doing wrong, as I followed the example from the following paper http://anson.ucdavis.edu/~hiwang/teaching/10fall/R_tutorial%201.pdf , page 4 as a guide. I also tried sleepfit <- survfit(Surv(timeb, death==1), data = sleep) and sleepfit <- survfit(Surv(starttime, endtime, death), data = sleep) Can anyone tell me what I might be doing wrong? Thanks, Lucy [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.