Re: [Rd] [R] unvectorized option for outer()

2005-11-01 Thread Duncan Murdoch
On 11/1/2005 10:16 AM, Thomas Lumley wrote: > On Tue, 1 Nov 2005, Duncan Murdoch wrote: > >> The version I posted yesterday did indeed mess up when some arguments were >> unspecified. Here's a revision that seems to work in all the tests I can >> think of. I also added the SIMPLIFY and USE.NAM

Re: [Rd] [R] unvectorized option for outer()

2005-11-01 Thread Thomas Lumley
On Tue, 1 Nov 2005, Duncan Murdoch wrote: > The version I posted yesterday did indeed mess up when some arguments were > unspecified. Here's a revision that seems to work in all the tests I can > think of. I also added the SIMPLIFY and USE.NAMES args from mapply to it, > and a sanity check to

Re: [Rd] [R] unvectorized option for outer()

2005-11-01 Thread Duncan Murdoch
The version I posted yesterday did indeed mess up when some arguments were unspecified. Here's a revision that seems to work in all the tests I can think of. I also added the SIMPLIFY and USE.NAMES args from mapply to it, and a sanity check to the args. I did notice and work around one buglet

Re: [Rd] [R] unvectorized option for outer()

2005-10-31 Thread Duncan Murdoch
Here's my entry for Vectorize: Vectorize <- function(FUN, vectorize.args = names(fargs)) { fargs <- formals(FUN) dovec <- match(vectorize.args, names(fargs)) FUNV <- function() { # will set the formals below args <- as.list(match.call())[-1] args <- lapply(arg

Re: [Rd] [R] unvectorized option for outer()

2005-10-31 Thread Tony Plate
Duncan Murdoch wrote: > On 10/31/2005 2:15 PM, Tony Plate wrote: > >> [snipped comments irrelevant to this post] >> >> So, here's a first pass at a general Vectorize() function: >> >> Vectorize <- function(FUN, vectorize.args) { >> if (!all(is.element(vectorize.args, names(formals(FUN) >>

Re: [Rd] [R] unvectorized option for outer()

2005-10-31 Thread Duncan Murdoch
On 10/31/2005 2:33 PM, Gabor Grothendieck wrote: > On 10/31/05, Tony Plate <[EMAIL PROTECTED]> wrote: >> >> I have to confess I don't really understand how environments work with >> functions, so I don't know if this Vectorize() function will work in >> general. What is the appropriate environment

Re: [Rd] [R] unvectorized option for outer()

2005-10-31 Thread Duncan Murdoch
On 10/31/2005 2:15 PM, Tony Plate wrote: > When I read the preface to The Blue Book (The New S Language, Becker, > Chambers & Wilks) I see comments along the lines of "high-level > language", "primary goal of the S environment is to enable and encourage > good data analysis", etc. While vectori

Re: [Rd] [R] unvectorized option for outer()

2005-10-31 Thread Thomas Lumley
On Mon, 31 Oct 2005, Liaw, Andy wrote: >> From: Thomas Lumley >> >> On Sun, 30 Oct 2005, Jonathan Rougier wrote: >> >>> I'm not sure about this. Perhaps I am a dinosaur, but my feeling is >>> that if people are writing functions in R that might be subject to >>> simple operations like outer produ

Re: [Rd] [R] unvectorized option for outer()

2005-10-31 Thread Gabor Grothendieck
On 10/31/05, Tony Plate <[EMAIL PROTECTED]> wrote: > > I have to confess I don't really understand how environments work with > functions, so I don't know if this Vectorize() function will work in > general. What is the appropriate environment for returned value of > Vectorize()? Is this approach

Re: [Rd] [R] unvectorized option for outer()

2005-10-31 Thread Tony Plate
When I read the preface to The Blue Book (The New S Language, Becker, Chambers & Wilks) I see comments along the lines of "high-level language", "primary goal of the S environment is to enable and encourage good data analysis", etc. While vectorization is a great feature of S (and R), I don't

Re: [Rd] [R] unvectorized option for outer()

2005-10-31 Thread Liaw, Andy
> From: Thomas Lumley > > On Sun, 30 Oct 2005, Jonathan Rougier wrote: > > > I'm not sure about this. Perhaps I am a dinosaur, but my feeling is > > that if people are writing functions in R that might be subject to > > simple operations like outer products, then they ought to be writing > > vec

Re: [Rd] [R] unvectorized option for outer()

2005-10-30 Thread Peter Dalgaard
Thomas Lumley <[EMAIL PROTECTED]> writes: > On Sun, 30 Oct 2005, Jonathan Rougier wrote: > > > I'm not sure about this. Perhaps I am a dinosaur, but my feeling is > > that if people are writing functions in R that might be subject to > > simple operations like outer products, then they ought to

Re: [Rd] [R] unvectorized option for outer()

2005-10-30 Thread Thomas Lumley
On Sun, 30 Oct 2005, Jonathan Rougier wrote: > I'm not sure about this. Perhaps I am a dinosaur, but my feeling is > that if people are writing functions in R that might be subject to > simple operations like outer products, then they ought to be writing > vectorised functions! I would agree. H

Re: [Rd] [R] unvectorized option for outer()

2005-10-30 Thread Jonathan Rougier
I'm not sure about this. Perhaps I am a dinosaur, but my feeling is that if people are writing functions in R that might be subject to simple operations like outer products, then they ought to be writing vectorised functions! Maybe it's not possible to hold this line, and maybe "outer" is not

Re: [Rd] [R] unvectorized option for outer()

2005-10-28 Thread Gabor Grothendieck
If the default were changed to VECTORIZED=FALSE then it would still be functionally compatible with what we have now so all existing software would continue to run correctly yet would not cause problems for the unwary. Existing software would not have to be changed to add VECTORIZED=TRUE except fo