YOu need to update the survival package: from its NEWS file
Changes in version 2.36-14
A supposedly cosmetic change to coxph in the last release caused
formulas with a "." on the right hand side to fail. Fix this and add a
case with "." to the test suite.
-thomas
On Thu, Jul 26, 2012 at 3:26 PM, Peter Langfelder
<peter.langfelder at gmail.com> wrote:> 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
>
> ______________________________________________
> 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.
--
Thomas Lumley
Professor of Biostatistics
University of Auckland