[R] 'fixing' list components

Thomas Lumley thomas at biostat.washington.edu
Wed Sep 20 19:28:58 CEST 2000

On Wed, 20 Sep 2000, Griffith Feeney wrote:

> I have a list x (say) that will contain many inputs to and outputs a model.
> x$input1 <- assign.input1(parameter1, parameter2)
> is one way to assign input1, but it would be neater to be able to do
> assign.input1(x, parameter1, parameter2)
> Is this a good idea? If so, what is a good way to do it?


You can do it using assign() or eval() in the parent frame, but 
  a) this is often a sign that what you're doing is a bad idea
  b) the syntax suggests that something like
    should work, but it won't.
  c) the code will  just be a complicated and fragile way of constructing
the command
  d) It will be particularly tricky since the assign() function, the
obvious way of doing it, doesn't handle things like "x$input1" the way you
would expect.


Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list