[R] I don't understand this

Thomas Lumley tlumley at u.washington.edu
Tue Sep 2 20:27:00 CEST 2003

On Tue, 2 Sep 2003, Simon Fear wrote:

> Please choose answer:
> a) you beat me to it making a great point
> b) it's got two too many pairs of braces in it, that's whats wrong with
> it!
> But seriously, I am sure Richard O'K had no intention of doing any such
> thing.
> The question was just about the syntax of R, no?
> Isn't it the case that
> (expr)(expr)
> is incorrect syntax under any circumstances?


It's *usually* incorrect, but not always

  power<-function(lambda) function(x) x^lambda


is perfectly valid.

You could also define, say, %*% to be a composition operator on some group
of functions and write
  (f %*% g)(x)
quite sensibly.

It may be the case that (expr)(expr)<-  is always invalid.


More information about the R-help mailing list