[R] To update() or not to update()?

Ko-Kang Kevin Wang kwan022 at stat.auckland.ac.nz
Mon May 19 11:31:27 CEST 2003


Hi,

Suppose I have:
  # Fit a base model
  d1.ph <- coxph(Surv(start, stop, event)~
               ejec + diavol + score + smoking +
               beta + surg.done,
               data = data.frame(foo))

  summary(update(d1.ph, . ~ . + td1))
  summary(update(d1.ph, . ~ . + td2)) 

As I have many columns in my data frame, foo, called td's.  e.g. td1, td2, 
td3, ....  And I'd like to add one column each time.  What is the 
recommended way to do this?  Whether I should do what I did above, or 
should I do something like:
  td1.ph <- coxph(Surv(start, stop, event)~
                ejec + diavol + score + smoking + 
                beta + surg.done + td1,
                data = data.frame(foo)) 

  td2.ph <- coxph(Surv(start, stop, event)~
                ejec + diavol + score + smoking + 
                beta + surg.done + td2,
                data = data.frame(foo))  

I've done a system.time() on it and update() doesn't seem to be much (if 
at all) faster.  Is there an advantage of using update() then (other than 
that the codes look neater)?


-- 
Cheers,

Kevin

------------------------------------------------------------------------------
/* Time is the greatest teacher, unfortunately it kills its students */

--
Ko-Kang Kevin Wang
Master of Science (MSc) Student
SLC Tutor and Lab Demonstrator
Department of Statistics
University of Auckland
New Zealand
Homepage: http://www.stat.auckland.ac.nz/~kwan022
Ph: 373-7599
    x88475 (City)
    x88480 (Tamaki)




More information about the R-help mailing list