Dear friends
Hope you all are fine. Suppose we have a list of arrays.
a1=c(4,4,4,4,0,4,4,4,0,3,3,0,0,0,0,0);  a1=array(a1,dim=c(4,4));  
a2=c(4,4,4,4,0,4,4,4,0,3,3,0,0,0,0,0);  a2=array(a2,dim=c(4,4));  
a3=c(4,4,4,4,0,3,3,4,0,4,4,0,0,0,0,0); a3=array(a3,dim=c(4,4)); 
a4=c(4,4,4,4,4,0,3,3,3,3,0,4,4,4,0,0,0,0,0,0); a4=array(a4,dim=c(5,4)); 
a5=c(4,4,4,4,4,0,4,4,4,4,0,3,3,3,0,0,1,1,0,0); a5=array(a5,dim=c(5,4)); 
a6=c(4,4,4,4,4,0,1,1,1,1,0,4,4,4,0,0,3,3,0,0); a6=array(a6,dim=c(5,4)); 
a7=c(1,1,1,1,1,0,4,4,4,4,0,3,3,3,0,0,4,4,0,0); a7=array(a7,dim=c(5,4)); 
a8=c(4,4,4,4,4,0,3,3,3,3,0,1,1,1,0,0,4,4,0,0); a8=array(a8,dim=c(5,4));
l=list(a1,a2,a3,a4,a5,a6,a7,a8); 

x <- sapply(1:length(l), function(x) {
  sum(sapply(l, function(y) {
    if ( nrow(l[[x]]) != nrow(y) | ncol(l[[x]]) != ncol(y) ) FALSE
    else sum(y != l[[x]]) == 0
  }))
} ); l; x

Using the above function, we are able to get frequency of each most repeated 
similar components of the list. For example, [[1]] and [[2]] are most repeated 
similar out of all. But if we consider the "combinations" at each row of each 
array. Then [[3]] will be included with [[1]] and [[2]]. Also [[5]], [[6]] and 
[[8]] will be similar. How can we modify the above function to get the desired 
most repeated sequence in this case? Any help in this regard is needed. 

best regards
M.Azam   



      
        [[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