[Rpy] help with the package survival
Hi, I have a problem with the package "survival" in rpy. I have to use the function survit() , and it works with R but not by calling R from python with rpy : >>> ss=r.survfit(s,weights=pds)Traceback (most recent call last): File >>> "", line 1, in ?RPy_RException: Erreur dans >>> UseMethod("survfit") : pas de méthode applicable pour "survfit" It seems that there is nothing implemented in rpy for this function... Do you know how I can manage this problem ? Have I made mistakes ? Or do you know what function I could use to have similar results ? If I can provide more information please let me know.best regards, Lore. Notes : Perhaps I can code again the survfit() function in pyton... But that seems really complicated. I have tried but first, I don't know if I have to code it as a python function (def...) or a R function (function () {...}). And then, there is a lot of problems such as with the function match.call() which can be used from outside a function... function (formula, data, weights, subset, na.action, ...) {call <- match.call()if ((mode(call[[2]]) == "call" && call[[2]][[1]] == as.name("Surv")) || inherits(formula, "Surv")) {formula <- eval(parse(text = paste(deparse(call[[2]]), 1, sep = "~"))) environment(formula) <- parent.frame()}if (!inherits(formula, "formula")) temp <- UseMethod("survfit")else {m <- match.call(expand.dots = FALSE)m$... <- NULLTerms <- terms(formula, "strata")ord <- attr(Terms, "order")if (length(ord) & any(ord != 1)) stop("Interaction terms are not valid for this function")m$formula <- Termsm[[1]] <- as.name("model.frame")m <- eval(m, parent.frame())n <- nrow(m) Y <- model.extract(m, "response")if (!is.Surv(Y)) stop("Response must be a survival object")casewt <- model.extract(m, "weights")if (is.null(casewt)) casewt <- rep(1, n) if (!is.null(attr(Terms, "offset"))) warning("Offset term ignored") ll <- attr(Terms, "term.labels")if (length(ll) == 0) X <- factor(rep(1, n))else X <- strata(m[ll])temp <- survfit.km(X, Y, casewt, ...)class(temp) <- "survfit"if (!is.null(attr(m, "na.action"))) temp$na.action <- attr(m, "na.action")}temp$call <- calltemp} _ Microsoft vous recommande de mettre à jour Internet Explorer. http://specials.fr.msn.com/IE7P25- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list
Re: [Rpy] help with the package survival
On Thu, Feb 21, 2008 at 8:08 AM, Lore Merdrignac <[EMAIL PROTECTED]> wrote: > > Hi, > I have a problem with the package "survival" in rpy. I have to use the > function survit() , and it works with R but not by calling R from python > with rpy : > > >>> ss=r.survfit(s,weights=pds) > Traceback (most recent call last): > File "", line 1, in ? > RPy_RException: Erreur dans UseMethod("survfit") : pas de méthode applicable > pour "survfit" > > It seems that there is nothing implemented in rpy for this function... > Do you know how I can manage this problem ? Have I made mistakes ? Or do > you know what function I could use to have similar results ? Lore, You'll probably need to show how you construct "s", as it seems that survfit is looking for a particular type of object. If "s" is not a formula or a coxph object, that would explain the error. Note that there is type-conversion going on in rpy, so even though "s" might have started out as the correct type of object, it may not be by the time you are calling the function here. Sean - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list
Re: [Rpy] help with the package survival
2008/2/21, Lore Merdrignac <[EMAIL PROTECTED]>: > > > Date: Thu, 21 Feb 2008 08:16:10 -0500 > > From: [EMAIL PROTECTED] > > To: rpy-list@lists.sourceforge.net > > Subject: Re: [Rpy] help with the package survival > > > > > On Thu, Feb 21, 2008 at 8:08 AM, Lore Merdrignac <[EMAIL PROTECTED]> > wrote: > > > > > > Hi, > > > I have a problem with the package "survival" in rpy. I have to use the > > > function survit() , and it works with R but not by calling R from python > > > with rpy : > > > > > > >>> ss=r.survfit(s,weights=pds) > > > Traceback (most recent call last): > > > File "", line 1, in ? > > > RPy_RException: Erreur dans UseMethod("survfit") : pas de méthode > applicable > > > pour "survfit" > > > > > > It seems that there is nothing implemented in rpy for this function... > > > Do you know how I can manage this problem ? Have I made mistakes ? Or do > > > you know what function I could use to have similar results ? > > > > Lore, > > > > You'll probably need to show how you construct "s", as it seems that > > survfit is looking for a particular type of object. If "s" is not a > > formula or a coxph object, that would explain the error. Note that > > there is type-conversion going on in rpy, so even though "s" might > > have started out as the correct type of object, it may not be by the > > time you are calling the function here. > > > > Sean > > > - > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ > > ___ > > rpy-list mailing list > > rpy-list@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/rpy-list > > > > Thank you for your reply Sean. > > So, this is how I proceed with R : > > d=rep(1,41) > > t=c( rep(6,5), rep(9,3) , rep(12,24), rep(15,9) ) > > plot(survfit(Surv(t,d))) > And I get a graph of life span. > > With rpy : > >>> from rpy import r > >>> r.library("survival") > >>> d=r.rep(1,41) > >>> t=r.c( r.rep(6,5), r.rep(9,3) , r.rep(12,24), r.rep(15,9) ) > >>> r.plot(r.survfit(r.Surv(t,d))) > Traceback (most recent call last): > File "", line 1, in ? > RPy_RException: Erreur dans UseMethod("survfit") : pas de méthode applicable > pour "survfit" > > Or : > >>> s=r.Surv(t,d) > >>> ss=r.survfit(s) > Traceback (most recent call last): > File "", line 1, in ? > RPy_RException: Erreur dans UseMethod("survfit") : pas de méthode applicable > pour "survfit" > > Is there a mistake...? Not really... it is just that the conversion Sean was referring to seems to be happening (and is causing confusion - there are improvements coming on that front, but that will be for an other post). You can try turning the conversion off with rpy.set_default_mode(rpy.NO_CONVERSION) prior to running your code. > Thank you for your time Sean. > > Lore. > > > > > > > Windows Live Messenger 2008 vient de sortir, encore plus de fun ! > Téléchargez gratuitement Messenger 2008 > - > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ > ___ > rpy-list mailing list > rpy-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rpy-list > > -- -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) iEYEARECAAYFAkYgwJ4ACgkQB/w/MLoyRDeQlgCeMp8v69/Wy24Q4IaBVhoG1M5R 2h4AoIOTvKbrFpTklRDjV7u8tEOeSQqt =JPph -END PGP SIGNATURE- - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list
Re: [Rpy] help with the package survival
> Date: Thu, 21 Feb 2008 08:16:10 -0500> From: [EMAIL PROTECTED]> To: > rpy-list@lists.sourceforge.net> Subject: Re: [Rpy] help with the package > survival> > On Thu, Feb 21, 2008 at 8:08 AM, Lore Merdrignac <[EMAIL > PROTECTED]> wrote:> >> > Hi,> > I have a problem with the package "survival" > in rpy. I have to use the> > function survit() , and it works with R but not > by calling R from python> > with rpy :> >> > >>> ss=r.survfit(s,weights=pds)> > > Traceback (most recent call last):> > File "", line 1, > in ?> > RPy_RException: Erreur dans UseMethod("survfit") : pas de méthode > applicable> > pour "survfit"> >> > It seems that there is nothing implemented > in rpy for this function...> > Do you know how I can manage this problem ? > Have I made mistakes ? Or do> > you know what function I could use to have > similar results ?> > Lore,> > You'll probably need to show how you construct > "s", as it seems that> survfit is looking for a particular type of object. If > "s" is not a> formula or a coxph object, that would explain the error. Note > that> there is type-conversion going on in rpy, so even though "s" might> > have started out as the correct type of object, it may not be by the> time > you are calling the function here.> > Sean> > -> > This SF.net email is sponsored by: Microsoft> Defy all challenges. > Microsoft(R) Visual Studio 2008.> > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/> > ___> rpy-list mailing list> > rpy-list@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/rpy-list Thank you for your reply Sean. So, this is how I proceed with R : > d=rep(1,41)> t=c( rep(6,5), rep(9,3) , rep(12,24), rep(15,9) )> > plot(survfit(Surv(t,d)))And I get a graph of life span. With rpy : >>> from rpy import r>>> r.library("survival")>>> d=r.rep(1,41)>>> t=r.c( >>> r.rep(6,5), r.rep(9,3) , r.rep(12,24), r.rep(15,9) )>>> >>> r.plot(r.survfit(r.Surv(t,d)))Traceback (most recent call last): File >>> "", line 1, in ?RPy_RException: Erreur dans >>> UseMethod("survfit") : pas de méthode applicable pour "survfit" Or : >>> s=r.Surv(t,d)>>> ss=r.survfit(s)Traceback (most recent call last): File >>> "", line 1, in ?RPy_RException: Erreur dans >>> UseMethod("survfit") : pas de méthode applicable pour "survfit" Is there a mistake...? Thank you for your time Sean. Lore. _ Nouveau ! Créez votre profil Messenger ! http://home.services.spaces.live.com/- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list
Re: [Rpy] help with the package survival
> Date: Thu, 21 Feb 2008 14:48:10 +0100> From: [EMAIL PROTECTED]> To: > rpy-list@lists.sourceforge.net> Subject: Re: [Rpy] help with the package > survival> > 2008/2/21, Lore Merdrignac <[EMAIL PROTECTED]>:> >> > > Date: > Thu, 21 Feb 2008 08:16:10 -0500> > > From: [EMAIL PROTECTED]> > > To: > rpy-list@lists.sourceforge.net> > > Subject: Re: [Rpy] help with the package > survival> >> > >> > > On Thu, Feb 21, 2008 at 8:08 AM, Lore Merdrignac > <[EMAIL PROTECTED]>> > wrote:> > > >> > > > Hi,> > > > I have a problem with > the package "survival" in rpy. I have to use the> > > > function survit() , > and it works with R but not by calling R from python> > > > with rpy :> > > > >> > > > >>> ss=r.survfit(s,weights=pds)> > > > Traceback (most recent call > last):> > > > File "", line 1, in ?> > > > RPy_RException: > Erreur dans UseMethod("survfit") : pas de méthode> > applicable> > > > pour > "survfit"> > > >> > > > It seems that there is nothing implemented in rpy for > this function...> > > > Do you know how I can manage this problem ? Have I > made mistakes ? Or do> > > > you know what function I could use to have > similar results ?> > >> > > Lore,> > >> > > You'll probably need to show how > you construct "s", as it seems that> > > survfit is looking for a particular > type of object. If "s" is not a> > > formula or a coxph object, that would > explain the error. Note that> > > there is type-conversion going on in rpy, > so even though "s" might> > > have started out as the correct type of object, > it may not be by the> > > time you are calling the function here.> > >> > > > Sean> > >> > > -> > > > This SF.net email is sponsored by: Microsoft> > > Defy all challenges. > Microsoft(R) Visual Studio 2008.> > > > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/> > > > ___> > > rpy-list mailing list> > > > rpy-list@lists.sourceforge.net> > > > https://lists.sourceforge.net/lists/listinfo/rpy-list> >> >> >> > Thank you > for your reply Sean.> >> > So, this is how I proceed with R :> > > > d=rep(1,41)> > > t=c( rep(6,5), rep(9,3) , rep(12,24), rep(15,9) )> > > > plot(survfit(Surv(t,d)))> > And I get a graph of life span.> >> > With rpy :> > > >>> from rpy import r> > >>> r.library("survival")> > >>> d=r.rep(1,41)> > > >>> t=r.c( r.rep(6,5), r.rep(9,3) , r.rep(12,24), r.rep(15,9) )> > >>> > r.plot(r.survfit(r.Surv(t,d)))> > Traceback (most recent call last):> > File > "", line 1, in ?> > RPy_RException: Erreur dans > UseMethod("survfit") : pas de méthode applicable> > pour "survfit"> >> > Or > :> > >>> s=r.Surv(t,d)> > >>> ss=r.survfit(s)> > Traceback (most recent call > last):> > File "", line 1, in ?> > RPy_RException: Erreur > dans UseMethod("survfit") : pas de méthode applicable> > pour "survfit"> >> > > Is there a mistake...?> > Not really... it is just that the conversion Sean > was referring to> seems to be happening> (and is causing confusion - there > are improvements coming on that> front, but that will> be for an other > post).> > You can try turning the conversion off with> > rpy.set_default_mode(rpy.NO_CONVERSION)> prior to running your code.> I have just tried but it does not seem to work ... Below there is what I got : >>> rpy.set_default_mode(rpy.NO_CONVERSION)Traceback (most recent call last): >>> File "", line 1, in ?NameError: name 'rpy' is not defined >>> r.set_default_mode(r.NO_CONVERSION)Traceback (most recent call last): File >>> "", line 1, in ? File >>> "C:\Python24\Lib\site-packages\rpy.py", line 302, in __getattr__return >>> self.__getitem__(name) File "C:\Python24\Lib\site-packages\rpy.py", line >>> 306, in __getitem__obj = self.__dict__[name] = self.__dict__.get(name, >>> self.get(name))RPy_RException: Erreur dans function (x, pos = -1, envir = >>> as.environment(pos), mode = "any", : variable "set.default.mode" >>> introuvable >>> r.set_default_mode(rpy.NO_CONVERSION)Traceback (most recent call last): >>> File "", line 1, in ? File >>> "C:\Python24\Lib\site-packages\rpy.py", line 302, in __getattr__return >>> self.__getitem__(name) File "C:\Python24\Lib\site-packages\rpy.py", line >>> 306, in __getitem__obj = self.__dict__[name] = self.__dict__.get(name, >>> self.get(name))RPy_RException: Erreur dans function (x, pos = -1, envir = >>> as.environment(pos), mode = "any", : variable "set.default.mode" >>> introuvable Is there any other solution :$ ? Thanks for answering. Lore. > > > Thank you for your time Sean.> >> > Lore.> >> >> >> >> >> > > > > > > Windows Live Messenger 2008 vient de > > > sortir, encore plus de fun !> > Téléchargez gratuitement Messenger 2008> > > > > > > > -> > > > > This SF.net email is sponsored by: Microsoft> > Defy all challenges. >
Re: [Rpy] help with the package survival
> Date: Thu, 21 Feb 2008 15:03:52 +0100> From: [EMAIL PROTECTED]> To: > rpy-list@lists.sourceforge.net> Subject: Re: [Rpy] help with the package > survival> > May be importing rpy with> > import rpy> > does help ?> > > > > > > 2008/2/21, Lore Merdrignac <[EMAIL PROTECTED]>:> >> > > Date: Thu, 21 Feb > 2008 14:48:10 +0100> > > From: [EMAIL PROTECTED]> >> > > To: > rpy-list@lists.sourceforge.net> > > Subject: Re: [Rpy] help with the package > survival> > >> > > 2008/2/21, Lore Merdrignac <[EMAIL PROTECTED]>:> > > >> > > > > > Date: Thu, 21 Feb 2008 08:16:10 -0500> > > > > From: [EMAIL PROTECTED]> > > > > > To: rpy-list@lists.sourceforge.net> > > > > Subject: Re: [Rpy] help > with the package survival> > > >> > > > >> > > > > On Thu, Feb 21, 2008 at > 8:08 AM, Lore Merdrignac> > <[EMAIL PROTECTED]>> > > > wrote:> > > > > >> > > > > > > Hi,> > > > > > I have a problem with the package "survival" in rpy. I > have to use> > the> > > > > > function survit() , and it works with R but not > by calling R from> > python> > > > > > with rpy :> > > > > >> > > > > > >>> > ss=r.survfit(s,weights=pds)> > > > > > Traceback (most recent call last):> > > > > > > File "", line 1, in ?> > > > > > RPy_RException: > Erreur dans UseMethod("survfit") : pas de méthode> > > > applicable> > > > > > > pour "survfit"> > > > > >> > > > > > It seems that there is nothing > implemented in rpy for this> > function...> > > > > > Do you know how I can > manage this problem ? Have I made mistakes ?> > Or do> > > > > > you know > what function I could use to have similar results ?> > > > >> > > > > Lore,> > > > > >> > > > > You'll probably need to show how you construct "s", as it > seems that> > > > > survfit is looking for a particular type of object. If > "s" is not a> > > > > formula or a coxph object, that would explain the > error. Note that> > > > > there is type-conversion going on in rpy, so even > though "s" might> > > > > have started out as the correct type of object, it > may not be by the> > > > > time you are calling the function here.> > > > >> > > > > > Sean> > > > >> > > >> > > -> > > > > > This SF.net email is sponsored by: Microsoft> > > > > Defy all > challenges. Microsoft(R) Visual Studio 2008.> > > > >> > > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/> > > > > > ___> > > > > rpy-list mailing > list> > > > > rpy-list@lists.sourceforge.net> > > > > > https://lists.sourceforge.net/lists/listinfo/rpy-list> > > >> > > >> > > >> > > > > Thank you for your reply Sean.> > > >> > > > So, this is how I proceed > with R :> > > > > d=rep(1,41)> > > > > t=c( rep(6,5), rep(9,3) , rep(12,24), > rep(15,9) )> > > > > plot(survfit(Surv(t,d)))> > > > And I get a graph of > life span.> > > >> > > > With rpy :> > > > >>> from rpy import r> > > > >>> > r.library("survival")> > > > >>> d=r.rep(1,41)> > > > >>> t=r.c( r.rep(6,5), > r.rep(9,3) , r.rep(12,24), r.rep(15,9) )> > > > >>> > r.plot(r.survfit(r.Surv(t,d)))> > > > Traceback (most recent call last):> > > > > File "", line 1, in ?> > > > RPy_RException: Erreur dans > UseMethod("survfit") : pas de méthode> > applicable> > > > pour "survfit"> > > > >> > > > Or :> > > > >>> s=r.Surv(t,d)> > > > >>> ss=r.survfit(s)> > > > > Traceback (most recent call last):> > > > File "", line 1, > in ?> > > > RPy_RException: Erreur dans UseMethod("survfit") : pas de > méthode> > applicable> > > > pour "survfit"> > > >> > > > Is there a > mistake...?> > >> > > Not really... it is just that the conversion Sean was > referring to> > > seems to be happening> > > (and is causing confusion - > there are improvements coming on that> > > front, but that will> > > be for > an other post).> > >> > > You can try turning the conversion off with> > > > rpy.set_default_mode(rpy.NO_CONVERSION)> > > prior to running your code.> > > >> >> > I have just tried but it does not seem to work ... Below there is > what I> > got :> >> > >>> rpy.set_default_mode(rpy.NO_CONVERSION)> > > Traceback (most recent call last):> > File "", line 1, in > ?> > NameError: name 'rpy' is not defined> >> > >>> > r.set_default_mode(r.NO_CONVERSION)> > Traceback (most recent call last):> > > File "", line 1, in ?> > File > "C:\Python24\Lib\site-packages\rpy.py", line 302, in> > __getattr__> > return > self.__getitem__(name)> > File "C:\Python24\Lib\site-packages\rpy.py", line > 306, in> > __getitem__> > obj = self.__dict__[name] = self.__dict__.get(name, > self.get(name))> > RPy_RException: Erreur dans function (x, pos = -1, envir > => > as.environment(pos), mode = "any", :> > variable "set.default.mode" > introuvable> >> > >>> r.set_default_mode(rpy.NO_CONVERSION)> > Traceback > (most recent call last):> > File "", line 1, in ?> > File > "C:\Python24\Lib\site-packages\rpy.py", line 302, in> > __getattr__> > return > self.__getitem__(name)> > File "C:\Pyth
Re: [Rpy] help with the package survival
May be importing rpy with import rpy does help ? 2008/2/21, Lore Merdrignac <[EMAIL PROTECTED]>: > > > Date: Thu, 21 Feb 2008 14:48:10 +0100 > > From: [EMAIL PROTECTED] > > > To: rpy-list@lists.sourceforge.net > > Subject: Re: [Rpy] help with the package survival > > > > 2008/2/21, Lore Merdrignac <[EMAIL PROTECTED]>: > > > > > > > Date: Thu, 21 Feb 2008 08:16:10 -0500 > > > > From: [EMAIL PROTECTED] > > > > To: rpy-list@lists.sourceforge.net > > > > Subject: Re: [Rpy] help with the package survival > > > > > > > > > > > On Thu, Feb 21, 2008 at 8:08 AM, Lore Merdrignac > <[EMAIL PROTECTED]> > > > wrote: > > > > > > > > > > Hi, > > > > > I have a problem with the package "survival" in rpy. I have to use > the > > > > > function survit() , and it works with R but not by calling R from > python > > > > > with rpy : > > > > > > > > > > >>> ss=r.survfit(s,weights=pds) > > > > > Traceback (most recent call last): > > > > > File "", line 1, in ? > > > > > RPy_RException: Erreur dans UseMethod("survfit") : pas de méthode > > > applicable > > > > > pour "survfit" > > > > > > > > > > It seems that there is nothing implemented in rpy for this > function... > > > > > Do you know how I can manage this problem ? Have I made mistakes ? > Or do > > > > > you know what function I could use to have similar results ? > > > > > > > > Lore, > > > > > > > > You'll probably need to show how you construct "s", as it seems that > > > > survfit is looking for a particular type of object. If "s" is not a > > > > formula or a coxph object, that would explain the error. Note that > > > > there is type-conversion going on in rpy, so even though "s" might > > > > have started out as the correct type of object, it may not be by the > > > > time you are calling the function here. > > > > > > > > Sean > > > > > > > > - > > > > This SF.net email is sponsored by: Microsoft > > > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > > > > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ > > > > ___ > > > > rpy-list mailing list > > > > rpy-list@lists.sourceforge.net > > > > https://lists.sourceforge.net/lists/listinfo/rpy-list > > > > > > > > > > > > Thank you for your reply Sean. > > > > > > So, this is how I proceed with R : > > > > d=rep(1,41) > > > > t=c( rep(6,5), rep(9,3) , rep(12,24), rep(15,9) ) > > > > plot(survfit(Surv(t,d))) > > > And I get a graph of life span. > > > > > > With rpy : > > > >>> from rpy import r > > > >>> r.library("survival") > > > >>> d=r.rep(1,41) > > > >>> t=r.c( r.rep(6,5), r.rep(9,3) , r.rep(12,24), r.rep(15,9) ) > > > >>> r.plot(r.survfit(r.Surv(t,d))) > > > Traceback (most recent call last): > > > File "", line 1, in ? > > > RPy_RException: Erreur dans UseMethod("survfit") : pas de méthode > applicable > > > pour "survfit" > > > > > > Or : > > > >>> s=r.Surv(t,d) > > > >>> ss=r.survfit(s) > > > Traceback (most recent call last): > > > File "", line 1, in ? > > > RPy_RException: Erreur dans UseMethod("survfit") : pas de méthode > applicable > > > pour "survfit" > > > > > > Is there a mistake...? > > > > Not really... it is just that the conversion Sean was referring to > > seems to be happening > > (and is causing confusion - there are improvements coming on that > > front, but that will > > be for an other post). > > > > You can try turning the conversion off with > > rpy.set_default_mode(rpy.NO_CONVERSION) > > prior to running your code. > > > > I have just tried but it does not seem to work ... Below there is what I > got : > > >>> rpy.set_default_mode(rpy.NO_CONVERSION) > Traceback (most recent call last): > File "", line 1, in ? > NameError: name 'rpy' is not defined > > >>> r.set_default_mode(r.NO_CONVERSION) > Traceback (most recent call last): > File "", line 1, in ? > File "C:\Python24\Lib\site-packages\rpy.py", line 302, in > __getattr__ > return self.__getitem__(name) > File "C:\Python24\Lib\site-packages\rpy.py", line 306, in > __getitem__ > obj = self.__dict__[name] = self.__dict__.get(name, self.get(name)) > RPy_RException: Erreur dans function (x, pos = -1, envir = > as.environment(pos), mode = "any", : > variable "set.default.mode" introuvable > > >>> r.set_default_mode(rpy.NO_CONVERSION) > Traceback (most recent call last): > File "", line 1, in ? > File "C:\Python24\Lib\site-packages\rpy.py", line 302, in > __getattr__ > return self.__getitem__(name) > File "C:\Python24\Lib\site-packages\rpy.py", line 306, in > __getitem__ > obj = self.__dict__[name] = self.__dict__.get(name, self.get(name)) > RPy_RException: Erreur dans function (x, pos = -1, envir = > as.environment(pos), mode = "any", : > variable "set.default.mode" introuvable > > Is there any other solution :$ ? Thanks for answering. > Lore. > > > > > > > Thank you for your time Sean. > > > > > > Lore. > > > > > > > > > > > > > > > > > > ___
Re: [Rpy] help with the package survival
On Thu, Feb 21, 2008 at 9:19 AM, Lore Merdrignac <[EMAIL PROTECTED]> wrote: > > > > Date: Thu, 21 Feb 2008 15:03:52 +0100 > > > > From: [EMAIL PROTECTED] > > To: rpy-list@lists.sourceforge.net > > Subject: Re: [Rpy] help with the package survival > > > > May be importing rpy with > > > > import rpy > > > > does help ? > > > > > > > > > > > > 2008/2/21, Lore Merdrignac <[EMAIL PROTECTED]>: > > > > > > > Date: Thu, 21 Feb 2008 14:48:10 +0100 > > > > From: [EMAIL PROTECTED] > > > > > > > To: rpy-list@lists.sourceforge.net > > > > Subject: Re: [Rpy] help with the package survival > > > > > > > > 2008/2/21, Lore Merdrignac <[EMAIL PROTECTED]>: > > > > > > > > > > > Date: Thu, 21 Feb 2008 08:16:10 -0500 > > > > > > From: [EMAIL PROTECTED] > > > > > > To: rpy-list@lists.sourceforge.net > > > > > > Subject: Re: [Rpy] help with the package survival > > > > > > > > > > > > > > > > > On Thu, Feb 21, 2008 at 8:08 AM, Lore Merdrignac > > > <[EMAIL PROTECTED]> > > > > > wrote: > > > > > > > > > > > > > > Hi, > > > > > > > I have a problem with the package "survival" in rpy. I have to > use > > > the > > > > > > > function survit() , and it works with R but not by calling R > from > > > python > > > > > > > with rpy : > > > > > > > > > > > > > > >>> ss=r.survfit(s,weights=pds) > > > > > > > Traceback (most recent call last): > > > > > > > File "", line 1, in ? > > > > > > > RPy_RException: Erreur dans UseMethod("survfit") : pas de > méthode > > > > > applicable > > > > > > > pour "survfit" > > > > > > > > > > > > > > It seems that there is nothing implemented in rpy for this > > > function... > > > > > > > Do you know how I can manage this problem ? Have I made mistakes > ? > > > Or do > > > > > > > you know what function I could use to have similar results ? > > > > > > > > > > > > Lore, > > > > > > > > > > > > You'll probably need to show how you construct "s", as it seems > that > > > > > > survfit is looking for a particular type of object. If "s" is not > a > > > > > > formula or a coxph object, that would explain the error. Note that > > > > > > there is type-conversion going on in rpy, so even though "s" might > > > > > > have started out as the correct type of object, it may not be by > the > > > > > > time you are calling the function here. > > > > > > > > > > > > Sean > > > > > > > > > > > > > > > - > > > > > > This SF.net email is sponsored by: Microsoft > > > > > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > > > > > > > > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ > > > > > > ___ > > > > > > rpy-list mailing list > > > > > > rpy-list@lists.sourceforge.net > > > > > > https://lists.sourceforge.net/lists/listinfo/rpy-list > > > > > > > > > > > > > > > > > > > > Thank you for your reply Sean. > > > > > > > > > > So, this is how I proceed with R : > > > > > > d=rep(1,41) > > > > > > t=c( rep(6,5), rep(9,3) , rep(12,24), rep(15,9) ) > > > > > > plot(survfit(Surv(t,d))) > > > > > And I get a graph of life span. > > > > > > > > > > With rpy : > > > > > >>> from rpy import r > > > > > >>> r.library("survival") > > > > > >>> d=r.rep(1,41) > > > > > >>> t=r.c( r.rep(6,5), r.rep(9,3) , r.rep(12,24), r.rep(15,9) ) > > > > > >>> r.plot(r.survfit(r.Surv(t,d))) > > > > > Traceback (most recent call last): > > > > > File "", line 1, in ? > > > > > RPy_RException: Erreur dans UseMethod("survfit") : pas de méthode > > > applicable > > > > > pour "survfit" > > > > > > > > > > Or : > > > > > >>> s=r.Surv(t,d) > > > > > >>> ss=r.survfit(s) > > > > > Traceback (most recent call last): > > > > > File "", line 1, in ? > > > > > RPy_RException: Erreur dans UseMethod("survfit") : pas de méthode > > > applicable > > > > > pour "survfit" > > > > > > > > > > Is there a mistake...? > > > > > > > > Not really... it is just that the conversion Sean was referring to > > > > seems to be happening > > > > (and is causing confusion - there are improvements coming on that > > > > front, but that will > > > > be for an other post). > > > > > > > > You can try turning the conversion off with > > > > rpy.set_default_mode(rpy.NO_CONVERSION) > > > > prior to running your code. > > > > > > > > > > I have just tried but it does not seem to work ... Below there is what I > > > got : > > > > > > >>> rpy.set_default_mode(rpy.NO_CONVERSION) > > > Traceback (most recent call last): > > > File "", line 1, in ? > > > NameError: name 'rpy' is not defined > > > > > > >>> r.set_default_mode(r.NO_CONVERSION) > > > Traceback (most recent call last): > > > File "", line 1, in ? > > > File "C:\Python24\Lib\site-packages\rpy.py", line 302, in > > > __getattr__ > > > return self.__getitem__(name) > > > File "C:\Python24\Lib\site-packages\rpy.py", line 306, in > > > __getitem__ > > > obj = self.__dict__[name] = self.__dict__.get(name, self.get(name)) > > > RPy_RException: Erreur dans function (
Re: [Rpy] help with the package survival
I still have the same error ... :( >>> from rpy import r>>> r.library("survival")Le chargement a nécessité le >>> package : splines['survival', 'splines', 'stats', 'graphics', 'grDevices', >>> 'utils', 'datasets', 'methods', 'base']>>> >>> rpy.set_default_mode(rpy.NO_CONVERSION)Traceback (most recent call last): >>> File "", line 1, in ?NameError: name 'rpy' is not >>> defined>>> r.set_default_mode(rpy.NO_CONVERSION)Traceback (most recent call >>> last): File "", line 1, in ? File >>> "C:\Python24\Lib\site-packages\rpy.py", line 302, in __getattr__return >>> self.__getitem__(name) File "C:\Python24\Lib\site-packages\rpy.py", line >>> 306, in __getitem__obj = self.__dict__[name] = self.__dict__.get(name, >>> self.get(name))RPy_RException: Erreur dans function (x, pos = -1, envir = >>> as.environment(pos), mode = "any", : variable "set.default.mode" >>> introuvable >>> import rpy>>> rpy.set_default_mode(rpy.NO_CONVERSION)>>> d=r.rep(1,41)>>> >>> t=r.c( r.rep(6,5), r.rep(9,3) , r.rep(12,24), r.rep(15,9) )>>> >>> r.plot(r.survfit(r.Surv(t,d)))Traceback (most recent call last): File >>> "", line 1, in ?RPy_RException: Erreur dans parse(text = >>> paste(deparse(call[[2]]), 1, sep = "~")) : unexpected numeric constant >>> dans :"structure(c(6L, 6L, 6L, 6L, 6L, 9L, 9L, 9L, 12L, 12L, 12L, 12L, >>> ~112L" > Date: Thu, 21 Feb 2008 10:35:36 -0500> From: [EMAIL PROTECTED]> To: > rpy-list@lists.sourceforge.net> Subject: Re: [Rpy] help with the package > survival> > On Thu, Feb 21, 2008 at 9:19 AM, Lore Merdrignac <[EMAIL > PROTECTED]> wrote:> >> > > > > Date: Thu, 21 > Feb 2008 15:03:52 +0100> >> > It was almost good ! But, since I am really > lucky, an other error> > appears... There is still an error in the function > survfit(), in spite of> > the "NO_CONVERSION".> >> > >>> import rpy> >> > >>> > rpy.set_default_mode(rpy.NO_CONVERSION)> > Do not use this until after doing > the library() call.> > > >>> from rpy import r> > >>> r.library("survival")> > > Le chargement a nécessité le package : splines> > 0x009FD390>> >> > Place the rpy.set_default_mode(rpy.NO_CONVERSION) HERE and > see what you get.> > > >>> d=r.rep(1,41)> > >>> t=r.c( r.rep(6,5), r.rep(9,3) > , r.rep(12,24), r.rep(15,9) )> > >>> r.plot(r.survfit(r.Surv(t,d)))> > Let us > know how it turns out> > Sean> > -> > This SF.net email is sponsored by: Microsoft> Defy all challenges. > Microsoft(R) Visual Studio 2008.> > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/> > ___> rpy-list mailing list> > rpy-list@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/rpy-list _ Nouveau ! Créez votre profil Messenger ! http://home.services.spaces.live.com/- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list
Re: [Rpy] help with the package survival
On Thu, Feb 21, 2008 at 10:50 AM, Lore Merdrignac <[EMAIL PROTECTED]> wrote: > > I still have the same error ... :( > > > >>> from rpy import r > >>> r.library("survival") > Le chargement a nécessité le package : splines > ['survival', 'splines', 'stats', 'graphics', 'grDevices', 'utils', > 'datasets', 'methods', 'base'] > > >>> rpy.set_default_mode(rpy.NO_CONVERSION) > Traceback (most recent call last): > File "", line 1, in ? > NameError: name 'rpy' is not defined Lore, You will probably need to do some reading on Python and R, but to fix this problem, you need to: import rpy as Laurent pointed out earlier. Sean - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list