[R] survexp - example produces error

Heinz Tuechler tuechler at gmx.at
Fri Dec 31 15:53:37 CET 2010


Dear Peter, Dear All,

a further attempt led me to an answer. If I set 
options(stringsAsFactors=TRUE), which I usually have set to FALSE, no 
error occurs.
I am, however not happy with this solution.

Heinz

Thank you, Peter

after setting options(error=recover), see the output below, once for 
frame number 2, which I suspect to be the problem, once for frame number 1.

Heinz

 > expect <-
+   survexp(futime ~ ratetable(age=(accept.dt - birth.dt),
+                              sex=1,year=accept.dt,race="white"),
+           jasa, cohort=FALSE,
+           ratetable=survexp.usr)
Error in floor(temp) : Non-numeric argument to mathematical function

Enter a frame number, or 0 to exit

1: survexp(futime ~ ratetable(age = (accept.dt - birth.dt), sex = 1, year = ac
2: match.ratetable(rdata, ratetable)

Selection: 2
Called from: top level
Browse[1]> temp
   [1] "white" "white" "white" "white" "white" "white" "white" "white" "white"
  [10] "white" "white" "white" "white" "white" "white" "white" "white" "white"
  [19] "white" "white" "white" "white" "white" "white" "white" "white" "white"
  [28] "white" "white" "white" "white" "white" "white" "white" "white" "white"
  [37] "white" "white" "white" "white" "white" "white" "white" "white" "white"
  [46] "white" "white" "white" "white" "white" "white" "white" "white" "white"
  [55] "white" "white" "white" "white" "white" "white" "white" "white" "white"
  [64] "white" "white" "white" "white" "white" "white" "white" "white" "white"
  [73] "white" "white" "white" "white" "white" "white" "white" "white" "white"
  [82] "white" "white" "white" "white" "white" "white" "white" "white" "white"
  [91] "white" "white" "white" "white" "white" "white" "white" "white" "white"
[100] "white" "white" "white" "white"
Browse[1]> Q
 >

There is also 'temp' in frame number 1.

 > expect <-
+   survexp(futime ~ ratetable(age=(accept.dt - birth.dt),
+                              sex=1,year=accept.dt,race="white"),
+           jasa, cohort=FALSE,
+           ratetable=survexp.usr)
Error in floor(temp) : Non-numeric argument to mathematical function

Enter a frame number, or 0 to exit

1: survexp(futime ~ ratetable(age = (accept.dt - birth.dt), sex = 1, year = ac
2: match.ratetable(rdata, ratetable)

Selection: 1
Called from: top level
Browse[1]> temp
  [1]   49    5   15   38   17    2  674   39   84   57  152    7 
80 1386    0
[16]  307   35   42   36   27 1031   50  732  218 1799 1400  262   71   34  851
[31]   76 1586 1571   11   99   65    4   52 1407 1321    1   44  995    8 1141
[46]  979  284  101  187   60  941  148  342  915   67   68  841  583   77   31
[61]  669   29  619  595   89   16  544   20  514   95  481  444  427   79  333
[76]  396  109  369  206  185  339  264  164  179  130  108   30   10
Browse[1]> Q



At 31.12.2010 13:46 +0100, peter dalgaard wrote:

>On Dec 31, 2010, at 10:21 , Heinz Tuechler wrote:
>
> > Dear All,
> >
> > reposting, because I did not find a solution, maybe someone could 
> check the example below.
> >
> > It's taken from the help page of survdiff. Executing it, gives the error
> >
> > "Error in floor(temp) : Non-numeric argument to mathematical function"
>
>Hmm, it's not happening to me (Mac OSX) either with 2.12.1 or the 
>current R-patched (r53892). Could be a platform issue (sounds 
>unlikely), a local user issue, or a locale one.
>
>Could you set options(error=recover) and find out what is the value 
>of "temp" when the error occurs?
>
> >
> > best regards,
> >
> > Heinz
> >
> > library(survival)
> >
> > ## Example from help page of survdiff
> > ## Expected survival for heart transplant patients based on
> > ## US mortality tables
> > expect <-
> >  survexp(futime ~ ratetable(age=(accept.dt - birth.dt),
> >                             sex=1,year=accept.dt,race="white"),
> >          jasa, cohort=FALSE,
> >          ratetable=survexp.usr)
> >
> > Error in floor(temp) : Non-numeric argument to mathematical function
> >
> > sessionInfo('survival')
> >
> > R version 2.12.1 Patched (2010-12-18 r53869)
> > Platform: i386-pc-mingw32/i386 (32-bit)
> >
> > locale:
> > [1] LC_COLLATE=German_Switzerland.1252  LC_CTYPE=German_Switzerland.1252
> > [3] LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C
> > [5] LC_TIME=German_Switzerland.1252
> >
> > attached base packages:
> > character(0)
> >
> > other attached packages:
> > [1] survival_2.36-2
> >
> > loaded via a namespace (and not attached):
> > [1] base_2.12.1      graphics_2.12.1  grDevices_2.12.1 methods_2.12.1
> > [5] splines_2.12.1   stats_2.12.1     tools_2.12.1     utils_2.12.1
> > > traceback()
> > 2: match.ratetable(rdata, ratetable)
> > 1: survexp(futime ~ ratetable(age = (accept.dt - birth.dt), sex = 1,
> >       year = accept.dt, race = "white"), jasa, cohort = FALSE,
> >       ratetable = survexp.usr)
> > >
> >
> > ______________________________________________
> > R-help at 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.
>
>--
>Peter Dalgaard
>Center for Statistics, Copenhagen Business School
>Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>Phone: (+45)38153501
>Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list