s-news
[Top] [All Lists]

Re: generating function arguments as string

To: s-news@lists.biostat.wustl.edu, Ronan.Bradley@ILIM.COM
Subject: Re: generating function arguments as string
From: Terry Therneau <therneau@mayo.edu>
Date: Mon, 19 Jul 2004 08:26:43 -0500 (CDT)
Reply-to: Terry Therneau <therneau@mayo.edu>
  A simple way to do what you ask is found in almost all the modeling
functions (lm, coxph, etc).

  At the top of the function, before manipulating any arguments, you
will find the line

        call <- match.call()
        
Then the "call" component is added to the output.  It contains a copy of the
what you typed to invoke the function.  So

        fit <- coxph(Surv(time, status) ~ age + height, data=mydata, x=T)
        
The phrase
        refit <- eval(fit$call)
will re-fit the model as originally specified.
        fit$call
will print the original call on the screen.

        Terry Therneau
        


<Prev in Thread] Current Thread [Next in Thread>