[R] Environment problems

Hans Gardfjell hans.gardfjell at emg.umu.se
Tue May 23 09:02:12 CEST 2006


Dear list readers,

Can someone of you explain this behavior. Here's a toy example:

Start by constructing a function tmp

 >fix(tmp)

In the default editor enter this one-liner:
hist(rnorm(10))

close the editor and run environment on the function.

 > environment(tmp)
<environment: R_GlobalEnv>

Open the editor and remove the last parenthesis, this will make the 
editor choke.

 > fix(tmp)
Error in edit(name, file, title, editor) :
        an error occurred on line 4
 use a command like
 x <- edit()
 to recover

Put the paranthesis back:

 > edit()->tmp

 > environment(tmp)
<environment: base>
 > tmp()
Error in tmp() : could not find function "hist"

And as you can see, the function doesn't work anymore...
Yes, I know I can manually change the environment back to .GlobalEnv, 
but is this the way it supposed to work?

This example is done in

 > R.Version()$version.string
[1] "Version 2.3.0 Patched (2006-04-25 r37924)"

on WindowsXP

Cheers, Hans

-- 

*********************************
Hans Gardfjell
Ecology and Environmental Science
Umeå University
90187 Umeå, Sweden
email: hans.gardfjell at emg.umu.se
phone:  +46 907865267
mobile: +46 705984464



More information about the R-help mailing list