Re: [R] Possible Improvement to sapply

2018-03-14 Thread Doran, Harold
' of this mailing list thread, "Possible Improvement", >*has* become true after all -- > >-- thanks to Henrik ! > >Martin Maechler >ETH Zurich > > > >> On Tue, Mar 13, 2018 at 9:21 AM, Doran, Harold wrote: >> > Quite possibly, and I¹ll look into that. As

Re: [R] Possible Improvement to sapply

2018-03-14 Thread Martin Maechler
ject' of this mailing list thread, "Possible Improvement", *has* become true after all -- -- thanks to Henrik ! Martin Maechler ETH Zurich > On Tue, Mar 13, 2018 at 9:21 AM, Doran, Harold wrote: > > Quite possibly, and I’ll look into that. Aside from the work I was doing, > >

Re: [R] Possible Improvement to sapply

2018-03-13 Thread Henrik Bengtsson
nto that. Aside from the work I was doing, > however, I wonder if there is a way such that sapply could avoid the overhead > of having to call the identical function to determine the conditional path. > > > > From: William Dunlap [mailto:wdun...@tibco.com] > Sent: Tuesday, Mar

Re: [R] Possible Improvement to sapply

2018-03-13 Thread William Dunlap via R-help
r...@roswellpark.org] > Sent: Tuesday, March 13, 2018 9:43 AM > To: Doran, Harold ; 'r-help@r-project.org' < > r-help@r-project.org> > Subject: Re: [R] Possible Improvement to sapply > > > > On 03/13/2018 09:23 AM, Doran, Harold wrote: > > While wo

Re: [R] Possible Improvement to sapply

2018-03-13 Thread Martin Maechler
, 2018 12:11 PM > To: Doran, Harold > Cc: r-help@r-project.org > Subject: Re: [R] Possible Improvement to sapply > Wouldn't that change how simplify='array' is handled? >> str(sapply(1:3, function(x)diag(x,5,2), simplify="array")) > int

Re: [R] Possible Improvement to sapply

2018-03-13 Thread Doran, Harold
, March 13, 2018 12:14 PM To: Doran, Harold Cc: Martin Morgan ; r-help@r-project.org Subject: Re: [R] Possible Improvement to sapply Could your code use vapply instead of sapply? vapply forces you to declare the type and dimensions of FUN's output and stops if any call to FUN does not matc

Re: [R] Possible Improvement to sapply

2018-03-13 Thread Doran, Harold
You’re right, it sure does. My suggestion causes it to fail when simplify = ‘array’ From: William Dunlap [mailto:wdun...@tibco.com] Sent: Tuesday, March 13, 2018 12:11 PM To: Doran, Harold Cc: r-help@r-project.org Subject: Re: [R] Possible Improvement to sapply Wouldn't that chang

Re: [R] Possible Improvement to sapply

2018-03-13 Thread William Dunlap via R-help
Wouldn't that change how simplify='array' is handled? > str(sapply(1:3, function(x)diag(x,5,2), simplify="array")) int [1:5, 1:2, 1:3] 1 0 0 0 0 0 1 0 0 0 ... > str(sapply(1:3, function(x)diag(x,5,2), simplify=TRUE)) int [1:10, 1:3] 1 0 0 0 0 0 1 0 0 0 ... > str(sapply(1:3, function(x)diag(x,

Re: [R] Possible Improvement to sapply

2018-03-13 Thread Doran, Harold
izable way. -Original Message- From: Martin Morgan [mailto:martin.mor...@roswellpark.org] Sent: Tuesday, March 13, 2018 9:43 AM To: Doran, Harold ; 'r-help@r-project.org' Subject: Re: [R] Possible Improvement to sapply On 03/13/2018 09:23 AM, Doran, Harold wrote: > While w

Re: [R] Possible Improvement to sapply

2018-03-13 Thread Martin Morgan
On 03/13/2018 09:23 AM, Doran, Harold wrote: While working with sapply, the documentation states that the simplify argument will yield a vector, matrix etc "when possible". I was curious how the code actually defined "as possible" and see this within the function if (!identical(simplify, FAL