Re: [R] 'fixing' list components

About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [R] 'fixing' list components
From: Thomas Lumley (thomas@biostat.washington.edu)
Date: Thu 21 Sep 2000 - 03:28:58 EST


Message-ID: <Pine.GSO.4.21.0009201013420.10332-100000@atlas.biostat.washington.edu>

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?

No.

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
         assign.input1(foo(y),parameter1,parameter2)
    should work, but it won't.
  c) the code will just be a complicated and fragile way of constructing
the command
        x<-assign.input(parameter1,parameter2)
  anyway
  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

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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Thu 01 Feb 2001 - 16:14:24 EST