On Jun 30, 2013, at 14:35 , Duncan Murdoch wrote:
On 13-06-29 11:58 PM, Greg Snow wrote:
If you want to write really confusing code it is possible to do:
`1` - 2
`1` + 1
and things like that, but it is probably a good idea not to.
This is actually pretty simple, as the White Knight
On 30/06/13 15:58, Greg Snow wrote:
If you want to write really confusing code it is possible to do:
`1` - 2
`1` + 1
and things like that, but it is probably a good idea not to.
Fortune?
cheers,
Rolf
__
R-help@r-project.org mailing
On 13-06-29 11:58 PM, Greg Snow wrote:
If you want to write really confusing code it is possible to do:
`1` - 2
`1` + 1
and things like that, but it is probably a good idea not to.
This is actually pretty simple, as the White Knight could tell you. `1`
is what the name of 2 is called.
On Jun 30, 2013, at 5:35 AM, Duncan Murdoch wrote:
On 13-06-29 11:58 PM, Greg Snow wrote:
If you want to write really confusing code it is possible to do:
`1` - 2
`1` + 1
and things like that, but it is probably a good idea not to.
This is actually pretty simple, as the White
-project.org; John Fox
Subject: Re: [R] Lexical scoping is not what I expect
I just realized this was also possible:
assign('TRUE', FALSE)
TRUE
[1] TRUE
get('TRUE')
[1] FALSE
but it is probably a different story.
Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: 206-667-4385 Web
If you want to write really confusing code it is possible to do:
`1` - 2
`1` + 1
and things like that, but it is probably a good idea not to.
On Fri, Jun 28, 2013 at 7:30 PM, Rolf Turner rolf.tur...@xtra.co.nz wrote:
On 29/06/13 02:54, John Fox wrote:
Dear Duncan and Steve,
Since
I too find R's lexical scoping rules straightforward.
However, I'd say that if your code relies on lexical
scoping to find something, you should probably rewrite your code.
Except of course that almost every function relies on lexical
scoping to some extent!
This could get messy,
On 28/06/2013 9:28 AM, S Ellison wrote:
I too find R's lexical scoping rules straightforward.
However, I'd say that if your code relies on lexical
scoping to find something, you should probably rewrite your code.
Except of course that almost every function relies on lexical
scoping
Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of Duncan Murdoch
Sent: Friday, June 28, 2013 9:40 AM
To: S Ellison
Cc: r-help@r-project.org
Subject: Re: [R] Lexical scoping is not what I expect
On 28/06/2013 9:28 AM, S Ellison wrote:
I
Subject: Re: [R] Lexical scoping is not what I expect
On 28/06/2013 9:28 AM, S Ellison wrote:
I too find R's lexical scoping rules straightforward.
However, I'd say that if your code relies on lexical
scoping to find something, you should probably rewrite your code.
Except
@r-project.org
Subject: Re: [R] Lexical scoping is not what I expect
On 28/06/2013 9:28 AM, S Ellison wrote:
I too find R's lexical scoping rules straightforward.
However, I'd say that if your code relies on lexical
scoping to find something, you should probably rewrite your code.
Except
, 2013 11:07 AM
To: John Fox
Cc: 'S Ellison'; r-help@r-project.org
Subject: Re: [R] Lexical scoping is not what I expect
On 28/06/2013 10:54 AM, John Fox wrote:
Dear Duncan and Steve,
Since Steve's example raises it, I've never understood why it's legal
to
change the built-in global
Dear Brian,
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of Prof Brian Ripley
Sent: Friday, June 28, 2013 11:16 AM
To: r-help@r-project.org
Subject: Re: [R] Lexical scoping is not what I expect
On 28/06/2013 15:54, John
On 29/06/13 02:54, John Fox wrote:
Dear Duncan and Steve,
Since Steve's example raises it, I've never understood why it's legal to
change the built-in global constants in R, including T and F. That just
seems to me to set a trap for users. Why not treat these as reserved
symbols, like TRUE,
I just realized this was also possible:
assign('TRUE', FALSE)
TRUE
[1] TRUE
get('TRUE')
[1] FALSE
but it is probably a different story.
Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle
On Fri, Jun 28,
I second Ellison sentiments of almost never. One main reason is readability on later
viewing.
Yes, as Duncan says global variables can sometimes be handy and make functions quick to
write, but using a formal argument in the call is always clearer.
Terry Therneau
On 06/27/2013 05:00 AM,
On 13-06-27 8:18 AM, Terry Therneau wrote:
I second Ellison sentiments of almost never. One main reason is readability
on later
viewing.
Yes, as Duncan says global variables can sometimes be handy and make functions
quick to
write, but using a formal argument in the call is always clearer.
Duncan,
I disagree with Duncan was not at all the intent of my note, but on rereading it does
have that flavor. Chastisement accepted. Due to the documentation angle I'd simply
change your original maybe to sometimes maybe. A bit more caution but the same message.
Terry T.
On 06/27/2013
I too find R's lexical scoping rules straightforward.
However, I'd say that if your code relies on lexical scoping to find
something, you should probably rewrite your code.
Except of course that almost every function relies on lexical scoping
to some extent!
Do you want:
f - function(a, b)
-Original Message-
It may be helpful not to worry about the technical details,
just to look at the source code defining the function: if it
is defined in a place where a variable can be seen, it can
see that variable.
I too find R's lexical scoping rules straightforward.
On 13-06-26 6:57 AM, S Ellison wrote:
-Original Message-
It may be helpful not to worry about the technical details,
just to look at the source code defining the function: if it
is defined in a place where a variable can be seen, it can
see that variable.
I too find R's lexical
On 13-06-24 9:22 PM, David Kulp wrote:
Indeed, I misread / misunderstood. I think it's a difficult concept
that's hard to explain and the example wasn't great. But thanks all for
straightening me out!
It seems like a really natural definition to me, but I'm used to it.
Once you get used to it
According to
http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-scope.pdf and
other examples online, I am to believe that R resolves variables using lexical
scoping by following the frames up the call stack. However, that's not working
for me. For example, the following code, taken
Hello,
The object 'a' exists if function f() not in the global environment
where g() is defined. R is in fact going up, but to the global
environment and not finding 'a'. Try, as an example, the following.
f - function(x) {
g - function(y) { y + a }
a - 5
g(x)
}
On Mon, Jun 24, 2013 at 4:27 PM, David Kulp dk...@fiksu.com wrote:
According to
http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-scope.pdf and
other examples online, I am to believe that R resolves variables using
lexical scoping by following the frames up the call stack.
f1- function(x){env- parent.frame();env$a-5; g(x)}
f1(2)
#[1] 7
f1(7)
#[1] 12
f1(5)
#[1] 10
A.K.
From: David Kulp dk...@fiksu.com
To: r-help@r-project.org r-help@r-project.org
Sent: Monday, June 24, 2013 4:27 PM
Subject: [R] Lexical scoping is not what I
I hope that Robert Gentleman is currently getting a thrill. :-)
[See fortune(lexical scoping).]
cheers,
Rolf Turner
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
On Jun 24, 2013, at 3:27 PM, David Kulp dk...@fiksu.com wrote:
According to
http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-scope.pdf and
other examples online, I am to believe that R resolves variables using
lexical scoping by following the frames up the call stack.
On 13-06-24 4:27 PM, David Kulp wrote:
According to
http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-scope.pdf and
other examples online, I am to believe that R resolves variables using lexical
scoping by following the frames up the call stack.
You appear to have misread it.
Indeed, I misread / misunderstood. I think it's a difficult concept that's hard
to explain and the example wasn't great. But thanks all for straightening me
out!
â
David Kulp
On Mon, Jun 24, 2013 at 6:44 PM, Duncan Murdoch murdoch.dun...@gmail.com
wrote:
On 13-06-24 4:27 PM, David Kulp
tibco.com
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf
Of David Kulp
Sent: Monday, June 24, 2013 6:22 PM
To: Duncan Murdoch
Cc: r-help@r-project.org
Subject: Re: [R] Lexical scoping is not what I expect
Indeed, I misread
31 matches
Mail list logo