diff --git a/R/des_info.R b/R/des_info.R index 2fcbc3d..2c38818 100644 --- a/R/des_info.R +++ b/R/des_info.R @@ -439,17 +439,23 @@ des_info <- function(design.obj, if(design == "split") { des <- design.obj$book + + numsp <- max(as.numeric(des$splots)) + lenblk <- as.vector(table(des$block)[1]) + numwp <- lenblk/numsp + des$wplots <- rep(rep(1:numwp, each = numsp), max(as.numeric(des$block))) + des <- des[, c(1, 3, 6, 2, 4, 5)] + spfacs <- c("plots", "block", "wplots", "splots") trtNams <- names(des[!is.element(names(des), spfacs)]) - + design.obj$book <- des des$treatments <- factor(paste(des[, trtNams[1]], des[, trtNams[2]], sep = "_")) # Number of treatments ntrt <- nlevels(des$treatments) - # Calculate direction of blocking xx <- c() rr <- nrows / brows diff --git a/R/design.R b/R/design.R index fea3882..a4d414b 100644 --- a/R/design.R +++ b/R/design.R @@ -156,11 +156,6 @@ design <- function(type, trt2 = sub_treatments, r = reps, seed = ifelse(is.numeric(seed), seed, 0)) - numsp <- max(as.numeric(outdesign$book$splots)) - lenblk <- as.vector(table(outdesign$book$block)[1]) - numwp <- lenblk/numsp - outdesign$book$wplots <- rep(rep(1:numwp, each = numsp), reps) - outdesign$book <- outdesign$book[, c(1, 3, 6, 2, 4, 5)] } else if(substr(tolower(type), 1, 7) == "crossed") { diff --git a/R/satab.R b/R/satab.R index 073382d..347fb83 100644 --- a/R/satab.R +++ b/R/satab.R @@ -1,6 +1,6 @@ #' Produces a skeletal ANOVA table #' -#' @param design.obj An `agricolae` design object. +#' @param design.obj A modified `agricolae` design object as output from des_info. #' #' @return Prints skeletal ANOVA table to console output. #' @@ -112,12 +112,12 @@ satab <- function(design.obj) { blkdf <- length(unique(design.obj$block)) - 1 totdf <- nrow(design.obj) - 1 numwplots <- nrow(design.obj) / length(unique(design.obj$splots)) - sp.facWdf <- length(unique(design.obj[, 5])) - 1 - wpresdf <- (numwplots - 1) - blkdf - sp.facWdf trtAdf <- length(unique(design.obj[, 5])) - 1 trtBdf <- length(unique(design.obj[, 6])) - 1 trtABdf <- trtAdf * trtBdf + + wpresdf <- (numwplots - 1) - blkdf - trtAdf errdf <- totdf - trtAdf - trtBdf - trtABdf - blkdf - wpresdf output <- paste0(format("Source of Variation", width = 45), "df", "\n") diff --git a/man/multiple_comparisons.Rd b/man/multiple_comparisons.Rd index 4abdb71..a4bb164 100644 --- a/man/multiple_comparisons.Rd +++ b/man/multiple_comparisons.Rd @@ -63,7 +63,12 @@ multiple_comparisons( \item{...}{Other arguments passed through to \code{predict.asreml()}.} } \value{ -A list containing a data frame with predicted means, standard errors, confidence interval upper and lower bounds, and significant group allocations (named \code{predicted_values}), as well as a plot visually displaying the predicted values (named \code{predicted_plot}). If some of the predicted values are aliased, a warning is printed, and the aliased treatment levels are returned in the output (named \code{aliased}). +A list containing a data frame with predicted means, standard errors, +confidence interval upper and lower bounds, and significant group +allocations (named \code{predicted_values}), as well as a plot visually +displaying the predicted values (named \code{predicted_plot}). If some of the +predicted values are aliased, a warning is printed, and the aliased +treatment levels are returned in the output (named \code{aliased}). } \description{ A function for comparing and ranking predicted means with Tukey's Honest Significant Difference (HSD) Test. @@ -111,9 +116,11 @@ my_iris <- iris my_iris$Petal.Length <- exp(my_iris$Petal.Length) # Create exponential response exp_model <- aov(Petal.Length ~ Species, data = my_iris) -resplot(exp_model) # Not a good residual plot +resplot(exp_model) # Residual plot shows problems +# Fit a new model using a log transformation of the response log_model <- aov(log(Petal.Length) ~ Species, data = my_iris) + resplot(log_model) # Looks much better # Display the ANOVA table for the model @@ -186,5 +193,6 @@ autoplot(pred.out) } \references{ -Jørgensen, E. & Pedersen, A. R. (1997). How to Obtain Those Nasty Standard Errors From Transformed Data - and Why They Should Not Be Used. \url{https://pure.au.dk/portal/en/publications/how-to-obtain-those-nasty-standard-errors-from-transformed-data--and-why-they-should-not-be-used(d649ca20-d15f-11db-8e26-000ea68e967b).html} +Jørgensen, E. & Pedersen, A. R. (1997). How to Obtain Those Nasty +Standard Errors From Transformed Data - and Why They Should Not Be Used. \url{https://pure.au.dk/portal/en/publications/how-to-obtain-those-nasty-standard-errors-from-transformed-data--and-why-they-should-not-be-used(d649ca20-d15f-11db-8e26-000ea68e967b).html} } diff --git a/man/satab.Rd b/man/satab.Rd index c07c1f8..9193712 100644 --- a/man/satab.Rd +++ b/man/satab.Rd @@ -7,7 +7,7 @@ satab(design.obj) } \arguments{ -\item{design.obj}{An \code{agricolae} design object.} +\item{design.obj}{A modified \code{agricolae} design object as output from des_info.} } \value{ Prints skeletal ANOVA table to console output.