R/blockingstructure.R

Defines functions blockingstructure

Documented in blockingstructure

#'@title Find block sizes in column
#'
#'@description Returns blocks
#'
#'@param blocklist Block list
#'@keywords internal
#'@return Returns the blocking structure given a vector of block ids
blockingstructure = function(blocklist) {
  blocklength = c()
  lengthblock = 1
  for (i in 1:length(blocklist)) {
    counter = 0
    if (lengthblock == 1) {
      for (j in i:length(blocklist)) {
        if (j == length(blocklist) && blocklist[i] == blocklist[j]) {
          counter = counter + 1
          blocklength = c(blocklength, counter)
          return(blocklength)
        }

        if (blocklist[i] == blocklist[j]) {
          counter = counter + 1
        } else {
          blocklength = c(blocklength, counter)
          lengthblock = counter
          break
        }
      }
    } else {
      lengthblock = lengthblock - 1
    }
  }
}

Try the skpr package in your browser

Any scripts or data that you put into this service are public.

skpr documentation built on May 29, 2024, 5:06 a.m.