# ANOVA for split plot experiment ----------------------------------------
#' ANOVA for split plot experiment and it's HSD test#'
#'
#' @param block vector of block factor
#' @param mplot vector of the main factor
#' @param splot vector of the split factor
#' @param y vector of a response variable
#' @examples
#' Packages.InstallandLoad(c('tidyverse','glue'))
#' @export
HSDAnalysis.sp.plot <- function(mplot,splot,block,y){
require(agricolae)
require(data.table)
require(tidyverse)
getSimplifyHSD <-function(hsd){
merge(hsd$means[c("y","std")],hsd$groups["groups"],by = "row.names") %>%
dplyr::rename(trt=`Row.names`,means=y)
}
spmodel <- sp.plot(block = block,pplot = mplot,splot =splot,Y = y)
ANOVA <- spmodel$ANOVA %>% as.data.table(keep.rownames=TRUE) %>% setnames(old="rn",new="fct")
HSD.mplot <- HSD.test(y = y,trt = mplot,DFerror = spmodel$gl.a,MSerror = spmodel$Ea) %>%
getSimplifyHSD
HSD.splot <- HSD.test(y = y,trt = splot,DFerror = spmodel$gl.b,MSerror = spmodel$Eb) %>%
getSimplifyHSD
HSD.interaction <- HSD.test(y = y,trt = interaction(mplot,splot),
DFerror = spmodel$gl.b,MSerror = spmodel$Eb) %>%
getSimplifyHSD
list(aov=ANOVA,mplot=HSD.mplot,splot=HSD.splot,interaction=HSD.interaction)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.