R/checkBalancedData.R

Defines functions checkBalancedData

#' @importFrom stats formula
checkBalancedData <- function(fixed_formula,data){
  tfixed=terms(fixed_formula,data=data)
  ho=attr(tfixed,"term.labels")[attr(tfixed,"order")==max(attr(tfixed,"order"))][1]
  mmho=model.matrix(formula(paste("~",ho,collapse="")),data=data)
  dataPerGroup=colSums(matrix(mmho[,attr(mmho,"assign")==1],nrow=NROW(mmho)))
  if(!(sum(!(dataPerGroup==dataPerGroup[1]))==0)){
    warning("The data are not balanced, the results may not be exact.")
  }
}

Try the permuco package in your browser

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

permuco documentation built on June 30, 2022, 9:05 a.m.