From: a.buness@dkfz.de Full_Name: Andreas Buness Version: 1.7.1 OS: Unix Submission from: (NULL) (193.174.53.122) I would like to ask you to enhance the apply function with an option drop=FALSE similar to the one existing for subsetting of arrays. Or any other mechanism to get control on the dimensionality of an object resulting from an apply call. This could facilitate more robust programming.

From: Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> a.buness@dkfz.de writes: > Full_Name: Andreas Buness > Version: 1.7.1 > OS: Unix > Submission from: (NULL) (193.174.53.122) > > > I would like to ask you to enhance the apply function > with an option drop=FALSE similar to the one existing > for subsetting of arrays. Or any other mechanism to get > control on the dimensionality of an object resulting > from an apply call. This could facilitate more robust > programming. Don't you mean simplify=TRUE similar to sapply()? This has been suggested a couple of times. Or how do you intend 'drop' to work? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907

From: Patrick Burns <pburns@pburns.seanet.com> I'm not sure if this is the original wish or not, but I have run into the following situation: I apply a function to a matrix, but the operation fails because the function expects a matrix (which in my mind is the one column or row at each go). The function doesn't see it that way because it only gets the data as a vector. Personally, I'd favor forcing the user to write a wrapper function that does as.matrix (possibly with a transpose) rather than cluttering up apply. Patrick Burns Burns Statistics patrick@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") Peter Dalgaard BSA wrote: >a.buness@dkfz.de writes: > > > >>Full_Name: Andreas Buness >>Version: 1.7.1 >>OS: Unix >>Submission from: (NULL) (193.174.53.122) >> >> >>I would like to ask you to enhance the apply function >>with an option drop=FALSE similar to the one existing >>for subsetting of arrays. Or any other mechanism to get >>control on the dimensionality of an object resulting >>from an apply call. This could facilitate more robust >>programming. >> >> > >Don't you mean simplify=TRUE similar to sapply()? This has been >suggested a couple of times. Or how do you intend 'drop' to work? > > >

From: A.Buness@dkfz-heidelberg.de 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))) NULL > 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))) NULL > 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.

NOTES: add drop=FALSE to apply()

Audit (from Jitterbug): Fri Aug 15 15:55:55 2003 dmurdoch moved from incoming to wishlist Tue Sep 14 09:22:37 2004 ripley changed notes