[R] converting apply output

2004-06-23 Thread Andrew Beckerman
Hi - platform powerpc-apple-darwin6.8 status major1 minor9.0 year 2004 I am trying to deal with the output of apply(). As indicated, when each call to 'FUN' returns a vector of length 'n', then 'apply' returns an array of dimension 'c(n, dim(X)[MARGIN])'. However, I would like

Re: [R] converting apply output

2004-06-23 Thread Eric Lecoutre
Hi, Why not try with the data.frame structure, wich internally yet consists in a list: lapply(as.data.frame(m1),function(x) which(x==1)) $V1 [1] 8 9 $V2 [1] 9 10 [...] Eric At 12:53 23/06/2004, Andrew Beckerman wrote: Hi - platform powerpc-apple-darwin6.8 status major1 minor9.0 year

Re: [R] converting apply output

2004-06-23 Thread Andrew Beckerman
Thanks eric... I figured this routine out as well. cvt-function(dat){ x-as.list(rep(0,dim(dat)[2])) for(i in 1:dim(dat)[2]){ x[[i]]-dat[,i] x}} # get ragged array of 1's dat-apply(mat,2,function(x) which(x==1)) # deal with this using cvt to creat list if(is.null(dim(dat))) dat2-dat else