> idx = c(1,3,5)
> as.formula(paste("Surv(time, status)~", paste("x", idx,
sep = "", collapse = "+")))
Surv(time, status) ~ x1 + x3 + x5
Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China
On Fri, Oct 3, 2008 at 1:32 PM, Xing Yuan <joe.yuan0309 at gmail.com>
wrote:> Dear R user,
>
> I got a question when using the coxph function. I have 5 covariates x1, x2,
> x3, x4, x5 and I want to write a function so that when given an indicator,
> e.g., c(1,3,5), I can fit the model as
> model=coxph(Surv(time, status)~x1+x3+x5). Any idea to play around the form
> of formula?
>
> Thank you very much!
>
> Xing Yuan
> University of Pittsburgh
>