R/calcblocksizes.R

Defines functions calcblocksizes

Documented in calcblocksizes

#'@title Calculate block sizes
#'
#'@description Calculate block size vector
#'
#'@param trials Number of trials in design
#'@param blocksize The desired size of each block
#'@return The blocksize vector
#'@keywords internal
calcblocksizes = function(trials, blocksize) {
  if (length(blocksize) > 1) {
    return(blocksize)
  }
  blocks = floor(trials / blocksize)
  extra = trials %% blocksize
  if (extra == 0) {
    extra = NULL
  }
  return(c(rep(blocksize, blocks), extra))
}

Try the skpr package in your browser

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

skpr documentation built on July 9, 2023, 7:23 p.m.