mw.intclose {ldsa}R Documentation

~~function to do ... ~~

Description

~~ A concise (1-5 lines) description of what the function does. ~~

Usage

mw.intclose(mb)

Arguments

mb ~~Describe mb here~~

Details

~~ If necessary, more details than the description above ~~

Value

~Describe the value returned If it is a LIST, use

comp1 Description of 'comp1'
comp2 Description of 'comp2'

...

Warning

....

Note

~~further notes~~

~Make other sections like Warning with section{Warning }{....} ~

Author(s)

~~who you are~~

References

~put references to the literature/web site here ~

See Also

~~objects to See Also as help, ~~~

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--    or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(mb){
  #Create a function to calculate binary values
  bv<-function(x)
    sum(2^(1:length(x)-1)*x)
  #First, if we've only been sent one sequence, return that one
  if(is.null(dim(mb))||(dim(mb)[1]==1))
    return(mb)
  #Calculate binary values for all lattice members
  lattice<-cbind(mb,apply(mb,1,bv))
  #Remove any duplicates  
  lattice<-lattice[!duplicated(lattice[,NCOL(mb)+1]),,drop=FALSE]
  #Perform a highly inefficient closure loop -- this could be greatly improved
  flag<-TRUE
  while(flag){
    flag<-FALSE
    for(i in 1:NROW(lattice))
      for(j in i:NROW(lattice)){
        meet<-lattice[i,1:NCOL(mb)]&lattice[j,1:NCOL(mb)]
        meetbv<-bv(meet)
        if(!any(lattice[,NCOL(mb)+1]==meetbv)){
          lattice<-rbind(lattice,c(meet,meetbv))
          flag<-TRUE
        }
      }
  }
  #Return the (reordered) result
  lattice[order(lattice[,NCOL(mb)+1]),1:NCOL(mb)]
  }

[Package ldsa version 0.1-2 Index]