[Rd] (PR#3690) wish in more detail

A.Buness at dkfz-heidelberg.de A.Buness at dkfz-heidelberg.de
Mon Aug 11 11:15:42 MEST 2003

I will try to clarify my wish regarding apply.

My wish is related to the dimension attribute of an object.
Of course by the nature of apply the dimension may change,
but as you can see in my artifical examples below the same 
apply-operation applied to a matrix does behave differently 
to that respect.

> dim(matrix(0,nrow=1,ncol=1))
[1] 1 1
> dim(apply(matrix(0,nrow=1,ncol=1),1,function(x) return(x)))

> dim(matrix(0,nrow=2,ncol=1))
[1] 2 1
> apply(matrix(0,nrow=2,ncol=1),1,function(x) return(x))
[1] 0 0
> dim(apply(matrix(0,nrow=2,ncol=1),1,function(x) return(x)))

> dim(matrix(0,nrow=1,ncol=2))
[1] 1 2
> dim(apply(matrix(0,nrow=1,ncol=2),1,function(x) return(x)))
[1] 2 1

In these examples I would expect "matrix-dimensions" for 
all cases instead of no dimensions at all in the first
two cases. A follow up apply-operation (expecting a matrix 
like object will fail) and programming is laborious.
This is the reason why I am asking for an extension
of apply like "drop=FALSE" as it exists for subsetting 
of arrays.

More information about the R-devel mailing list