[R] Environmental problems.
murdoch.duncan at gmail.com
Wed Feb 26 04:02:57 CET 2014
Rolf Turner wrote:
> Somehow I managed *not* to cc to R-help the message that I just sent to
> you. I thought I'd clicked on "Reply All" but apparently not. And in
> thrashing around trying to recover, I managed not to get a copy kept in
> my "Sent Mail"!!!
> Could I please prevail upon you to pass that message on to R-help? I
> think that there are some ideas of general interest that others might
> like to see.
So here is his reply:
On 14-02-25 9:00 PM, Rolf Turner wrote:
> On 26/02/14 11:29, Duncan Murdoch wrote:
>> One problem in your scrF: you have
>> tdone <- tt
>> rather than
>> tdone <<- tt
>> That creates a new local copy, it doesn't update the one in the parent
>> environment. That doesn't explain a "not found" error, but it would
>> cause problems...
> I have never understood the use of "<<-"; missed that notation in your
> example. Thanks for pointing it out.
>> The thing that causes the "not found" error is in xsolve.disc.R, where
>> you replace the environment of scrF with new.env(). That wipes out the
>> tiny one that local() created, and replaces it with an empty one whose
>> parent is the evaluation frame of xsolve.disc.
> That was a bit of a "duh", wasn't it? The reason for the new.env()
> stuff is my OCD tendency. I am always desperate to get rid of clutter
> and the default environment is filled with stuff that has no reason to
> be there IMHO. I guess the proper procedure would be to wrap each of
> the functions upon which I inflict "new.env()" in local() to start with,
> instead of mucking about with new.env() in that way.
>> Generally speaking it's a bad idea to replace the environment of
>> functions, it's hard to get it right. It's better to create the right
>> one in the first place.
> By using local()?
> Anyhow, having made the required changes, I now get the local() idea to
> Thank you!
> I would still like to know why I got the bizarre phenomenon that I
> initially got. It makes no sense. But that's just an academic question
> now, so I won't waste any more of your time on it.
> Thanks again.
More information about the R-help