RE: [R] I don't understand this

2003-09-03 Thread Simon Fear
Thanks to everyone for enlightening me about (f)(g). So I suppose (f)(g)(h)... is OK as long as (f)(g) returns a function with an argument (and so on)? Meanwhile, back on Earth, in attempting a compromise between the clarity of Barry R's if (cond) names(x) - 10 else dim(x) - 10 and the

Re: [R] I don't understand this

2003-09-03 Thread Barry Rowlingson
Simon Fear wrote: foo(x) - 10 Error: couldn't find function foo- this is because you defined 'foo', and not 'foo-', which are two different functions. if instead (or as well) you did: foo- - if (TRUE) get(names-) else get(dim-) then it works. Doesn't cure this one though: (foo)(x) - 10

Re: [R] I don't understand this

2003-09-03 Thread Peter Dalgaard BSA
Richard A. O'Keefe [EMAIL PROTECTED] writes: Thomas Lumley [EMAIL PROTECTED] wrote: I would have said that the behavior of (if (cond) names else dim)(x) - 10 is undefined in the S language, along with things like the order of evaluation of the apply functions.

RE: [R] I don't understand this

2003-09-03 Thread Thomas Lumley
On Wed, 3 Sep 2003, Simon Fear wrote: Thanks to everyone for enlightening me about (f)(g). So I suppose (f)(g)(h)... is OK as long as (f)(g) returns a function with an argument (and so on)? Indeed. As an example of what can be done recurse - function(f) { g- function(h)

Re: [R] I don't understand this

2003-09-03 Thread Thomas Lumley
On Wed, 3 Sep 2003, Richard A. O'Keefe wrote: Another assignment-related thing I'm not clear on is what f(x) - e is supposed to do. Me neither. f(x) - e is equivalent to x - f-(x, value=e) and x - e assigns to x in the next outer environment, but a simple

Re: [R] I don't understand this

2003-09-02 Thread Richard A. O'Keefe
I asked what x - NULL (if (TRUE) names else dim)(x) - 27 is *supposed* to do. Professor Brian Ripley basically gave me the answer I wanted: it isn't *supposed* to do anything. However, he went on to say And for R you have the source code, and a `R Language Definition'. My

Re: [R] I don't understand this

2003-09-02 Thread Peter Dalgaard BSA
Thomas Lumley [EMAIL PROTECTED] writes: I would have said that the behavior of (if (cond) names else dim)(x) - 10 is undefined in the S language, along with things like the order of evaluation of the apply functions. Actually, following Luke's analysis, I think it is pretty squarely an

Re: [R] I don't understand this

2003-09-02 Thread Barry Rowlingson
Peter Dalgaard BSA wrote: BTW: If you ever actually need to do something like that, try eval(substitute(foo(x)-10,list(foo=as.name(if (cond) names else dim please no!!! What's wrong with: if(cond){ names(x) - 10 } else { dim(x) - 10 } readable, obvious, maintainable,

Re: [R] I don't understand this

2003-09-02 Thread Peter Dalgaard BSA
Barry Rowlingson [EMAIL PROTECTED] writes: Peter Dalgaard BSA wrote: BTW: If you ever actually need to do something like that, try eval(substitute(foo(x)-10,list(foo=as.name(if (cond) names else dim please no!!! What's wrong with: if(cond){ names(x) - 10 } else {

Re: [R] I don't understand this

2003-09-02 Thread Richard A. O'Keefe
Thomas Lumley [EMAIL PROTECTED] wrote: I would have said that the behavior of (if (cond) names else dim)(x) - 10 is undefined in the S language, along with things like the order of evaluation of the apply functions. The thing is, it would make perfect