Skip to content

Commit

Permalink
improved RCBD
Browse files Browse the repository at this point in the history
  • Loading branch information
qddyy committed Sep 12, 2023
1 parent 9113175 commit ab57f15
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions R/RCBD.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,30 @@ RCBD <- R6Class(
k <- nrow(private$.data)
b <- ncol(private$.data)

private$.data_permu <- lapply(
X = permutations(
n = factorial(k), k = b, replace = TRUE,
nsample = private$.n_permu, layout = "list"
),
FUN = function(index, permus) {
do.call(
data.frame, .mapply(
dots = list(permus, index), MoreArgs = NULL,
FUN = function(permu, i) permu[[i]]
private$.data_permu <- if (is.null(private$.n_permu)) {
lapply(
X = permutations(
n = factorial(k), k = b, replace = TRUE, layout = "list"
),
FUN = function(index, permus) {
do.call(
data.frame, .mapply(
dots = list(permus, index), MoreArgs = NULL,
FUN = function(permu, i) permu[[i]]
)
)
)
}, permus = lapply(private$.data, permutations, layout = "list")
)
}, permus = lapply(private$.data, permutations, layout = "list")
)
} else {
lapply(
X = seq_len(private$.n_permu),
FUN = function(data, ...) {
do.call(
data.frame, lapply(data, function(x) x[sample.int(k)])
)
}, data = private$.data
)
}
},

.calculate_statistic = function() {
Expand Down

0 comments on commit ab57f15

Please sign in to comment.