Re: [R] understanding lexical scope

2008-12-20 Thread Peter Dalgaard
Wacek Kusnierczyk wrote: Peter Dalgaard wrote: One distinction is if you have things like #define f(x) 2*x #define g(y) f(y+2) (in the C language preprocessor syntax), then you end up with g(y) as y+2*2 (i.e., y+4), whereas the corresponding function calls give 2*(y+2). Also, and the flip side

Re: [R] understanding lexical scope

2008-12-20 Thread Wacek Kusnierczyk
Peter Dalgaard wrote: > > One distinction is if you have things like > > #define f(x) 2*x > #define g(y) f(y+2) > > (in the C language preprocessor syntax), then you end up with g(y) as > y+2*2 (i.e., y+4), whereas the corresponding function calls give > 2*(y+2). Also, and the flip side of the orig

Re: [R] understanding lexical scope

2008-12-20 Thread Wayne F
joseph.g.boyer wrote: > > Thomas, Jeff, Mark, Antonio, > > Thank you for your answers. They have helped me clarify how R functions > work. They work differently from SAS functions (which SAS calls macros.) > > To me, while the coding is quite awkward, the execution is logical. The > variabl

Re: [R] understanding lexical scope

2008-12-20 Thread Peter Dalgaard
Nordlund, Dan (DSHS/RDA) wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of joseph.g.bo...@gsk.com Sent: Friday, December 19, 2008 7:41 AM To: Thomas Lumley Cc: r-help@r-project.org Subject: Re: [R] understanding lexical

Re: [R] understanding lexical scope

2008-12-19 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of > joseph.g.bo...@gsk.com > Sent: Friday, December 19, 2008 7:41 AM > To: Thomas Lumley > Cc: r-help@r-project.org > Subject: Re: [R] understanding l

Re: [R] understanding lexical scope

2008-12-19 Thread joseph . g . boyer
Thomas, Jeff, Mark, Antonio, Thank you for your answers. They have helped me clarify how R functions work. They work differently from SAS functions (which SAS calls macros.) If you know SAS, consider the following code: * %macro q(y); data one; outvar = &y. + &x.; output; c

Re: [R] understanding lexical scope

2008-12-18 Thread Thomas Lumley
On Thu, 18 Dec 2008 joseph.g.bo...@gsk.com wrote: I am trying to understand the concept of lexical scope in "An Introduction to R" by the R Core development team. I'd appreciate it if someone would explain why the following example does not work: q <- function(y) {x + y}; w <- function(x){q(x)

Re: [R] understanding lexical scope

2008-12-18 Thread Antonio, Fabio Di Narzo
2008/12/18 : > I am trying to understand the concept of lexical scope in "An Introduction > to R" by the R Core development team. > > I'd appreciate it if someone would explain why the following example does > not work: > > q <- function(y) {x + y}; w <- function(x){q(x)}; w(2); > > According to t

[R] understanding lexical scope

2008-12-18 Thread joseph . g . boyer
I am trying to understand the concept of lexical scope in "An Introduction to R" by the R Core development team. I'd appreciate it if someone would explain why the following example does not work: q <- function(y) {x + y}; w <- function(x){q(x)}; w(2); According to the discussion of Scope on p