When I try to the code from library(survival) of library(ISwR),
the following code survfit(Surv(days,status==1)) that could produce Kaplan-Meier estimates shows the following error "Error in survfit(Surv(days, status == 1)) : Survfit requires a formula or a coxph fit as the first argument" How it can be done in R.2.10 |
you need:
survfit(Surv(days, status == 1) ~ 1) I hope it helps. Best, Dimitris On 4/19/2010 4:44 AM, ericyujin99 wrote: > > When I try to the code from library(survival) of library(ISwR), > > the following code > > survfit(Surv(days,status==1)) > > that could produce Kaplan-Meier estimates shows the following error > > "Error in survfit(Surv(days, status == 1)) : > Survfit requires a formula or a coxph fit as the first argument" > > How it can be done in R.2.10 -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 ______________________________________________ [hidden email] 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. |
done it, again, i have the next problem
my traduction: "The object (list) cannot be corced as "double" Original: km1 <- survfit(Surv(as.numeric(T.201110))~1) Error en Surv(as.numeric(T.201110)) : el objeto (list) no puede ser coercionado a 'double' note that need it convert to numeric class, otherwise: km1 <- survfit(Surv((T.201110))~1) Error en Surv((T.201110)) : Time variable is not numeric |
On Dec 10, 2011, at 6:39 PM, capitantyler wrote: > done it, again, i have the next problem > > my traduction: > "The object (list) cannot be corced as "double" > > Original: > *km1 <- survfit(Surv(as.numeric(T.201110))~1)* > Error en Surv(as.numeric(T.201110)) : > el objeto (list) no puede ser coercionado a 'double' I do not read that language, but I am surprised to see a single vector being used as an argument to Surv(). When I use Surv(. , .) it is with two vectors, an interval and a censor variable. > > note that need it convert to numeric class, otherwise: > > *km1 <- survfit(Surv((T.201110))~1)* > Error en Surv((T.201110)) : Time variable is not numeric > -- > View this message in context: http://r.789695.n4.nabble.com/Kaplan-Meier-survfit-problem-tp2015369p4181476.html Context? Yes. We do want context, but we don't want to go to no steenking Nabble. > Sent from the R help mailing list archive at Nabble.com. > Arrrgh. The rhelp mailing list is NOT at Nabble. Nabbel si a commercial mirror of the real thing. And it isn't really an archive. either, since they start discarding posts after a year or two. -- David Winsemius, MD West Hartford, CT ______________________________________________ [hidden email] 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. |
2011/12/11 Esteban Cervetto <[hidden email]>
> I am working with uncensored data. > > I have duration of workers compensation. Then I have for each the number > of days thet it doesn't work. > This sample is not censored at right because I query only work accidents > with date of return of work (saned) > > That is because I have only one vector: the number of days that the worker > doesn't work. > Reading works that uses this library, noticed that it need's a vector to > mark the type of termination. That is because I did a formula Y(x) = 1 > as.numeric(T.**201110))~1 > > Your words were inspired me to do this: I solvet it putting to T.201110 > this proper vector and a vector of ones. > T.201110$censor <- apply(T.201110,1,function(row) 1) ##is there a best method to do that? it takes much time I believe that this vector is superfluous, because the result of the formula is ever 1 > km1<-survfit(Surv(T.201110$dias,T.201110$censor)~1) > > > 2011/12/10 David Winsemius <[hidden email]> > >> >> On Dec 10, 2011, at 6:39 PM, capitantyler wrote: >> >> done it, again, i have the next problem >>> >>> my traduction: >>> "The object (list) cannot be corced as "double" >>> >>> Original: >>> *km1 <- survfit(Surv(as.numeric(T.**201110))~1)* >>> Error en Surv(as.numeric(T.201110)) : >>> el objeto (list) no puede ser coercionado a 'double' >>> >> >> I do not read that language, but I am surprised to see a single vector >> being used as an argument to Surv(). When I use Surv(. , .) it is with two >> vectors, an interval and a censor variable. >> >> >> >>> note that need it convert to numeric class, otherwise: >>> >>> *km1 <- survfit(Surv((T.201110))~1)* >>> Error en Surv((T.201110)) : Time variable is not numeric >>> -- >>> View this message in context: http://r.789695.n4.nabble.com/** >>> Kaplan-Meier-survfit-problem-**tp2015369p4181476.html<http://r.789695.n4.nabble.com/Kaplan-Meier-survfit-problem-tp2015369p4181476.html> >>> >> >> Context? Yes. We do want context, but we don't want to go to no steenking >> Nabble. >> >> >> Sent from the R help mailing list archive at Nabble.com. >>> >>> Arrrgh. The rhelp mailing list is NOT at Nabble. Nabbel si a commercial >> mirror of the real thing. And it isn't really an archive. either, since >> they start discarding posts after a year or two. >> >> -- >> David Winsemius, MD >> West Hartford, CT >> >> > [[alternative HTML version deleted]] ______________________________________________ [hidden email] 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. |
On Dec 11, 2011, at 5:48 PM, Esteban Cervetto wrote: > 2011/12/11 Esteban Cervetto <[hidden email]> > >> I am working with uncensored data. >> >> I have duration of workers compensation. Then I have for each the >> number >> of days thet it doesn't work. >> This sample is not censored at right because I query only work >> accidents >> with date of return of work (saned) >> >> That is because I have only one vector: the number of days that the >> worker >> doesn't work. >> Reading works that uses this library, noticed that it need's a >> vector to >> mark the type of termination. That is because I did a formula Y(x) >> = 1 >> as.numeric(T.**201110))~1 >> >> Your words were inspired me to do this: I solvet it putting to T. >> 201110 >> this proper vector and a vector of ones. >> > > T.201110$censor <- apply(T.201110,1,function(row) 1) ##is > there a > best method to do that? it takes much time > > I believe that this vector is superfluous, because the result of > the > formula is ever 1 You may be correct. The help page for Surv says "Although unusual, the event indicator can be omitted, in which case all subjects are assumed to have an event." > > >> km1<-survfit(Surv(T.201110$dias,T.201110$censor)~1) >> >> > > >> 2011/12/10 David Winsemius <[hidden email]> >> >>> >>> On Dec 10, 2011, at 6:39 PM, capitantyler wrote: >>> >>> done it, again, i have the next problem >>>> >>>> my traduction: >>>> "The object (list) cannot be corced as "double" >>>> >>>> Original: >>>> *km1 <- survfit(Surv(as.numeric(T.**201110))~1)* If you are adding the "**" for emphasis, it is certainly confusing my understanding of what your original code was, which i'm now wondering you ever provided. Perhaps it was the lack of a data argument. Hard to tell. This "works": > fit <- survfit(Surv(time) ~ 1, data = aml[aml$status==1, ]) > plot(fit) -- David >>>> Error en Surv(as.numeric(T.201110)) : >>>> el objeto (list) no puede ser coercionado a 'double' >>>> >>> >>> I do not read that language, but I am surprised to see a single >>> vector >>> being used as an argument to Surv(). When I use Surv(. , .) it is >>> with two >>> vectors, an interval and a censor variable. >>> >>> >>> >>>> note that need it convert to numeric class, otherwise: >>>> >>>> *km1 <- survfit(Surv((T.201110))~1)* >>>> Error en Surv((T.201110)) : Time variable is not numeric >>>> -- >>>> View this message in context: http://r.789695.n4.nabble.com/** >>>> Kaplan-Meier-survfit-problem-**tp2015369p4181476.html<http://r.789695.n4.nabble.com/Kaplan-Meier-survfit-problem-tp2015369p4181476.html >>>> > >>>> >>> >>> Context? Yes. We do want context, but we don't want to go to no >>> steenking >>> Nabble. >>> >>> >>> Sent from the R help mailing list archive at Nabble.com. >>>> >>>> Arrrgh. The rhelp mailing list is NOT at Nabble. Nabbel si a >>>> commercial >>> mirror of the real thing. And it isn't really an archive. either, >>> since >>> they start discarding posts after a year or two. >>> >>> -- >>> David Winsemius, MD >>> West Hartford, CT >>> >>> >> > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] 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. David Winsemius, MD West Hartford, CT ______________________________________________ [hidden email] 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. |
Free forum by Nabble | Edit this page |