Thanks you,

I can get the length of aa with length(unlist(aa)). If aa has 4 dimensions, I 
imagine I'd need to do

max(sapply(aa,sapply,sapply,length)

How can I do this in a generic way? That is in a loop. I am clear about the 
exit condition for the loop.

d<-1


start loop

if d = length(unlist(aa)) then exit loop 

else
    d<-d * <expr>


How do I construct <expr> such that it does  

> d<- d * length(aa)                      # first pass

> d<- d * max(sapply(aa, length))         # second pass

> d<- d * max(sapply(aa, sapply, length)) # third pass


> # ? #                                    # fourth path etc 


(Apologies for the pseudo code describing the loop; I am not near a machine 
with R)

One way I can thing of is to create a loop counter variable, say lc<-1 and to 
increment it within the loop and then use a switch statement to execute the 
appropriate expression. This sems like a kludge to me.

Is there a neater way?

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to