[Rd] error in apply help file? (PR#8118)

gunter.berton@gene.com gunter.berton at gene.com
Thu Sep 1 18:34:08 CEST 2005


Gents: (alas, I think no ladies need to be included in the salutation)

The apply()  Help file says
"...
If the calls to FUN return vectors of different lengths, apply returns a
list of length dim(X)[MARGIN]. "

Shouldn't that be:

"If the calls to FUN return vectors of different lengths, apply returns a
list of length prod(dim(X)[MARGIN]). "

Also, might you wish to add:

"This list has a dim attribute of MARGIN. That is, if VALUE is the returned
list, dim(VALUE) = MARGIN and the values in VALUE can be accessed by the
usual array subscripting operations."

Further, it might also be useful to add the following to your Examples code:

## Example with different lengths for each call
z <- array(1:24,dim=2:4)
zseq <- apply(z,1:2,function(x)seq(length=max(x)))
zseq  ## displayed as a 2 x 3 matrix
typeof(zseq) ## list
dim(zseq) ## 2 3
zseq[1,]


Feel free to ignore these suggestions, of course. 

Cheers,

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA



More information about the R-devel mailing list