Hi David,
Thank you!
Lucy

From: David Winsemius [via R] [mailto:ml-node+s789695n4686317h25@n4.nabble.com]
Sent: Thursday, 6 March 2014 8:38 PM
To: Lucy Leigh
Subject: Re: Survfit Error

The help page for the survfit function says it expects a formula as its first argument so try:

> sleepfit <- survfit(Surv(timeb, death)~1, data = sleep)

David
Sent from my iPhone ... so unable to test.

> On Mar 6, 2014, at 12:07 PM, Lucy Leigh <[hidden email]</user/SendEmail.jtp?type=node&node=4686317&i=0>> wrote:
>
>
> 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]]
>
> ______________________________________________
> [hidden email]</user/SendEmail.jtp?type=node&node=4686317&i=1> 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.

______________________________________________
[hidden email]</user/SendEmail.jtp?type=node&node=4686317&i=2> 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.

________________________________
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/Survfit-error-tp4686301p4686317.html
To start a new topic under R help, email ml-node+s789695n789696h74@n4.nabble.com<mailto:ml-node+s789695n789696h74@n4.nabble.com>
To unsubscribe from Survfit error, click here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4686301&code=THVjeS5MZWlnaEBuZXdjYXN0bGUuZWR1LmF1fDQ2ODYzMDF8MTgwNzAwNzgwNA==>.
NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://r.789695.n4.nabble.com/Survfit-error-tp4686301p4686356.html
Sent from the R help mailing list archive at Nabble.com.
	[[alternative HTML version deleted]]


