Re: [R] Function does not see variables outside the function

2013-11-06 Thread Zhong-Yuan Zhang
nal Message- > > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > > project.org] On Behalf Of Zhong-Yuan Zhang > > Sent: Wednesday, November 06, 2013 7:32 AM > > To: r-help@r-project.org > > Subject: Re: [R] Function does not see variables outside th

Re: [R] Function does not see variables outside the function

2013-11-06 Thread John Fox
[1] "g" I hope this helps, John > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Zhong-Yuan Zhang > Sent: Wednesday, November 06, 2013 7:32 AM > To: r-help@r-project.org > Subject: Re: [R] Function

Re: [R] Function does not see variables outside the function

2013-11-06 Thread Zhong-Yuan Zhang
Dear Experts: I am very appreciate your comments and help! Actually I am a new comer from MATLAB. If the function can see global variables, then it may output wrong results without any error messages. For example, there is a gloabl variable named v, and I write one funciton with one lo

Re: [R] Function does not see variables outside the function

2013-11-05 Thread Carl Witthoft
Why would you want to impose this restriction? Perhaps if you explain what you are trying to do, we can suggest approaches that will satisfy your specific needs. (note- one can always redefine whatever variables are to be "excluded." E.g. to keep the body of a function from referring to 'foo' in t

Re: [R] Function does not see variables outside the function

2013-11-05 Thread Prof Brian Ripley
On 05/11/2013 12:25, Rui Barradas wrote: Hello, I believe the answer is no. Functions will first look in their environment, and then in the parent frame, i.e., outside the function. That is not correct. The scoping rule when evaluatiing a function is to look first in the evaluation frame, th

Re: [R] Function does not see variables outside the function

2013-11-05 Thread Rui Barradas
Hello, I believe the answer is no. Functions will first look in their environment, and then in the parent frame, i.e., outside the function. Hope this helps, Rui Barradas Em 05-11-2013 10:42, Zhong-Yuan Zhang escreveu: Dear experts: In MATLAB, functions cannot see variables outside t

[R] Function does not see variables outside the function

2013-11-05 Thread Zhong-Yuan Zhang
Dear experts: In MATLAB, functions cannot see variables outside the functions. However, in R, the functions can do that. Is there any settings that can disable this ability of functions? Many thanks for your kind help. Best Regards Always. [[alternative HTML version de