Re: [R] A question regarding R scoping

2009-08-08 Thread Vitalie S.
<- 1 } after calling f1, the value of i becomes 1. Now, suppose that f1 is called in another function f2, and i is initialized in f2 as well, i.e: f2 = function(n){ i = n f1(i) } The intention is, after executing f2, i=1 (not i=n). --- On Thu, 8/6/09, Steve Lianoglou wrote: From: S

Re: [R] A question regarding R scoping

2009-08-07 Thread markleeds
__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Re: [R] A question regarding R scoping

2009-08-07 Thread Ivo Shterev
. Thank you very much for the help! Best Regards Ivo --- On Fri, 8/7/09, markle...@verizon.net wrote: > From: markle...@verizon.net > Subject: Re: Re: Re: [R] A question regarding R scoping > To: idc...@yahoo.com > Date: Friday, August 7, 2009, 6:57 PM > Hi Ivo: There's somet

Re: [R] A question regarding R scoping

2009-08-07 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Ivo Shterev > Sent: Friday, August 07, 2009 9:36 AM > To: murd...@stats.uwo.ca; markle...@verizon.net > Cc: r-help@r-project.org > Subject: Re: [R] A questio

Re: [R] A question regarding R scoping

2009-08-07 Thread Ivo Shterev
- On Fri, 8/7/09, markle...@verizon.net wrote: > From: markle...@verizon.net > Subject: Re: Re: [R] A question regarding R scoping > To: murd...@stats.uwo.ca > Cc: idc...@yahoo.com, r-help@r-project.org > Date: Friday, August 7, 2009, 8:33 AM > Hi Gabor, Steve, Eric and Duncan: I >

Re: [R] A question regarding R scoping

2009-08-06 Thread markleeds
__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Re: [R] A question regarding R scoping

2009-08-06 Thread Duncan Murdoch
(n){ i = n f1(i) } The intention is, after executing f2, i=1 (not i=n). That is what you get. What is the question? Duncan Murdoch --- On Thu, 8/6/09, Steve Lianoglou wrote: From: Steve Lianoglou Subject: Re: [R] A question regarding R scoping To: "Ivo Shterev" Cc: r-he

Re: [R] A question regarding R scoping

2009-08-06 Thread Gabor Grothendieck
length(n) > f1(i) > print(i)} > > i.e. f2 should print 1, not length(n). > > ivo > > > --- On Thu, 8/6/09, Steve Lianoglou wrote: > >> From: Steve Lianoglou >> Subject: Re: [R] A question regarding R scoping >> To: "Ivo Shterev" >> Cc

Re: [R] A question regarding R scoping

2009-08-06 Thread Ivo Shterev
} The intention is, after executing f2, i=1 (not i=n). --- On Thu, 8/6/09, Steve Lianoglou wrote: > From: Steve Lianoglou > Subject: Re: [R] A question regarding R scoping > To: "Ivo Shterev" > Cc: r-help@r-project.org > Date: Thursday, August 6, 2009, 10:23 PM > Howd

Re: [R] A question regarding R scoping

2009-08-06 Thread Erik Iverson
Sent: Thursday, August 06, 2009 3:11 PM To: Steve Lianoglou Cc: r-help@r-project.org Subject: Re: [R] A question regarding R scoping Hi, The intention is that after executing f2, the value of i to become 1. f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) print(i)} i.e. f2 should print 1

Re: [R] A question regarding R scoping

2009-08-06 Thread Duncan Murdoch
Lianoglou Subject: Re: [R] A question regarding R scoping To: "Ivo Shterev" Cc: r-help@r-project.org Date: Thursday, August 6, 2009, 3:07 AM Hi, On Aug 5, 2009, at 5:55 PM, Ivo Shterev wrote: > I have a question related to scoping. Suppose we have 2 functions: > > f1 = functio

Re: [R] A question regarding R scoping

2009-08-06 Thread Steve Lianoglou
Howdy, On Aug 6, 2009, at 4:11 PM, Ivo Shterev wrote: Hi, The intention is that after executing f2, the value of i to become 1. f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) print(i)} i.e. f2 should print 1, not length(n). Yeah, you can using parent.frame()'s and such: f

Re: [R] A question regarding R scoping

2009-08-06 Thread Ivo Shterev
Hi, The intention is that after executing f2, the value of i to become 1. f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) print(i)} i.e. f2 should print 1, not length(n). ivo --- On Thu, 8/6/09, Steve Lianoglou wrote: > From: Steve Lianoglou > Subject: Re: [R] A qu

Re: [R] A question regarding R scoping

2009-08-05 Thread Steve Lianoglou
Hi, On Aug 5, 2009, at 5:55 PM, Ivo Shterev wrote: I have a question related to scoping. Suppose we have 2 functions: f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) } In other words, I would like i=1 regardless of n. Is this possible without having f1 in the body of f2? Than

[R] A question regarding R scoping

2009-08-05 Thread Ivo Shterev
I have a question related to scoping. Suppose we have 2 functions: f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) } In other words, I would like i=1 regardless of n. Is this possible without having f1 in the body of f2? Thanks in advance!