[R] coxph weirdness

Peter Langfelder peter.langfelder at gmail.com
Fri Jul 27 00:26:45 CEST 2012


Hi all,

I cant' wrap my head around an error from the coxph function (package
survival). Here's an example:

library(survival)
n = 100;
set.seed(1);

time = rexp(n);
event = sample(c(0,1), n, replace = TRUE)
covar = data.frame(z = rnorm(n));

model = coxph(Surv(time, event)~ . , data = covar)

R gives the following error:

> model = coxph(Surv(time, event)~ . , data = covar)
Error in terms.formula(formula, specials = special) :
  '.' in formula and no 'data' argument

I read through the help file for coxph but nothing jumps out... what
am I doing wrong?

> sessionInfo()
R version 2.15.0 Patched (2012-04-01 r58897)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
 [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8
 [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8
 [7] LC_PAPER=C                LC_NAME=C
 [9] LC_ADDRESS=C              LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
[1] survival_2.36-13

loaded via a namespace (and not attached):
[1] tools_2.15.0

Thanks in advance for all replies!

Peter



More information about the R-help mailing list