I've just added a version of the improvements to R-devel. After some
discussion, we decided this should be a new function, not just a new arg
to sapply, and I chose vapply from among the 52 different suggestions
that were offered.
The usage is
vapply(X, FUN, FUN.VALUE, ..., USE.NAMES = TRUE
William Dunlap wrote:
...
if (x <= 0) NA else log(x)
variety otherwise.
Would you only want it to coerce upwards to FUN.VALUES's
type? E.g., allow
sapply(z, length, FUN.VALUE=numeric(1))
to return a numeric vector but die on
sapply(z, function(zi)as.complex(zi[1]), FUN.VALUE=numeric(1)
> -Original Message-
> From: Peter Dalgaard [mailto:p.dalga...@biostat.ku.dk]
> Sent: Wednesday, November 04, 2009 1:16 PM
> To: William Dunlap
> Cc: Duncan Murdoch; r-devel@r-project.org
> Subject: Re: [Rd] sapply improvements
>
> William Dunlap wrote:
> &
William Dunlap wrote:
It looks good on following examples:
z <- split(log(1:10), rep(letters[1:2],c(3,7)))
sapply(z, length, FUN.VALUE=numeric(1))
Error in sapply(z, length, FUN.VALUE = numeric(1)) :
FUN values must be of type 'double'
(I'd like the error to say "... must be of type 'doubl
> -Original Message-
> From: William Dunlap
> Sent: Wednesday, November 04, 2009 12:53 PM
> To: 'Duncan Murdoch'
> Cc: r-devel@r-project.org
> Subject: RE: sapply improvements
>
> It looks good on following examples:
>
> > z <- split(log(1:10), rep(letters[1:2],c(3,7)))
> > sapply(z, len
It looks good on following examples:
> z <- split(log(1:10), rep(letters[1:2],c(3,7)))
> sapply(z, length, FUN.VALUE=numeric(1))
Error in sapply(z, length, FUN.VALUE = numeric(1)) :
FUN values must be of type 'double'
(I'd like the error to say "... must be of type 'double',
not 'integer'", to
S4 generics can specify a valueClass. Perhaps that could be used in
those cases.
On Wed, Nov 4, 2009 at 3:24 PM, Duncan Murdoch wrote:
> On 11/4/2009 12:15 PM, William Dunlap wrote:
>>>
>>> -Original Message-
>>> From: r-devel-boun...@r-project.org
>>> [mailto:r-devel-boun...@r-project.o
On 11/4/2009 12:15 PM, William Dunlap wrote:
-Original Message-
From: r-devel-boun...@r-project.org
[mailto:r-devel-boun...@r-project.org] On Behalf Of Duncan Murdoch
Sent: Wednesday, November 04, 2009 8:47 AM
To: michael.m.spie...@gmail.com
Cc: r-b...@r-project.org; r-de...@stat.math.e