R/meansComp.R

Defines functions meansComp

Documented in meansComp

meansComp <- function(object, spec, graph=TRUE, ...){
  if (inherits(object, "LinearModel")){
    formule <- object$lmResult$call
	if ("selection"%in%names(formule)) formule <- formule[-which(names(formule)%in%"selection")]
    object <- eval(formule)
  }
  if (!inherits(object,"lm") & !inherits(object,"aov")) print("object must be of class LinearModel, lm or aov")
  tuk <- emmeans::emmeans(object,spec=spec, ...)
  mat <- matrix(NA,length(summary(tuk)[,1]),length(summary(tuk)[,1]))
  rownames(mat)=colnames(mat)=summary(tuk)[,1]
  aux <- summary(emmeans::contrast(tuk,"pairwise"))$p.value
  mat[lower.tri(mat)]<- aux
  mat <- t(mat)
  mat[lower.tri(mat)]<- aux
  mat <- mat[order(summary(tuk)[,2]),order(summary(tuk)[,2])]
  res <- list(adjMean=tuk, groupComp=multcompView::multcompLetters(mat))
  class(res) <- "meansComp"
  if (graph) print(plot(res))
  return(res)
}

Try the FactoMineR package in your browser

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

FactoMineR documentation built on Oct. 13, 2023, 1:06 a.m.