Skip to content

Commit

Permalink
Fixing up df in split plot satab
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerssam committed Aug 2, 2024
1 parent a634424 commit 5734000
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions R/des_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ des_info <- function(design.obj,
warning(names(fac.names)[2], " must contain the correct number of elements. Elements have not been applied.", call. = FALSE)
}

colnames(design.obj$book)[4:5] <- names(fac.names)[1:2]
colnames(design.obj$book)[colnames(design.obj$book) %in% c("treatments", "sub_treatments")] <- names(fac.names)[1:2]
}
else if(is.character(fac.names)) {
colnames(design.obj$book)[4:5] <- fac.names[1:2]
colnames(design.obj$book)[colnames(design.obj$book) %in% c("treatments", "sub_treatments")] <- fac.names[1:2]
}
}
}
Expand Down Expand Up @@ -453,7 +453,7 @@ des_info <- function(design.obj,
# Calculate direction of blocking
xx <- c()
rr <- nrows / brows
cc <- ncols / bcols
cc <- ncols / bcols
# Blocking across rows: brows == ntrt in a single column
if(brows == ntrt) {
plan <- expand.grid(row = 1:nrows, col = 1:ncols) # 2
Expand Down
12 changes: 6 additions & 6 deletions R/satab.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ 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[, 4])) - 1
sp.facWdf <- length(unique(design.obj[, 5])) - 1
wpresdf <- (numwplots - 1) - blkdf - sp.facWdf

trtAdf <- length(unique(design.obj[, 4])) - 1
trtBdf <- length(unique(design.obj[, 5])) - 1
trtAdf <- length(unique(design.obj[, 5])) - 1
trtBdf <- length(unique(design.obj[, 6])) - 1
trtABdf <- trtAdf * trtBdf
errdf <- totdf - trtAdf - trtBdf - trtABdf - blkdf - wpresdf

Expand All @@ -125,12 +125,12 @@ satab <- function(design.obj) {
output <- c(output, paste0(format("Block stratum", width = ifelse(blkdf>10, 44, 45)), blkdf, "\n"))
output <- c(output, paste0("--------------------------------------------------\n"))
output <- c(output, paste0("Whole plot stratum", "\n"))
output <- c(output, paste0(format(" ", width = 9), format(names(design.obj)[4], width = ifelse(trtAdf>10, 35, 36)), trtAdf, "\n"))
output <- c(output, paste0(format(" ", width = 9), format(names(design.obj)[5], width = ifelse(trtAdf>10, 35, 36)), trtAdf, "\n"))
output <- c(output, paste0(format("Whole plot Residual", width = 45), wpresdf, "\n"))
output <- c(output, paste0("==================================================\n"))
output <- c(output, paste0("Subplot stratum", "\n"))
output <- c(output, paste0(format(" ", width = 9), format(names(design.obj)[5], width = ifelse(trtBdf>10, 35, 36)), trtBdf, "\n"))
output <- c(output, paste0(format(" ", width = 9), format(paste(names(design.obj)[4], names(design.obj)[5], sep = ":"), width = ifelse(trtABdf>10, 35, 36)), trtABdf, "\n"))
output <- c(output, paste0(format(" ", width = 9), format(names(design.obj)[6], width = ifelse(trtBdf>10, 35, 36)), trtBdf, "\n"))
output <- c(output, paste0(format(" ", width = 9), format(paste(names(design.obj)[5], names(design.obj)[6], sep = ":"), width = ifelse(trtABdf>10, 35, 36)), trtABdf, "\n"))
output <- c(output, paste0(format(" ", width = 9), format("Subplot Residual", width = 35), errdf, "\n"))
output <- c(output, paste0("==================================================\n"))
output <- c(output, paste0(format("Total", width = ifelse(totdf>10, 44, 45)), totdf, "\n"))
Expand Down

0 comments on commit 5734000

Please sign in to comment.