Skip to content

Commit

Permalink
add sysetmatic-fastest and -slowest methods for assign_trts
Browse files Browse the repository at this point in the history
  • Loading branch information
emitanaka committed Oct 16, 2023
1 parent 06b2f5f commit 9f6b3ce
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions R/assign.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ assign_trts <- function(.edibble, order = "random", seed = NULL, constrain = nes
sub_ntrts <- nrow(sub_trts_df)
sub_nunits <- nrow(sub_units_df)
permute <- switch(order[igroup],
"systematic" = rep(1:sub_ntrts, length.out = sub_nunits),
"systematic-random" = rep(sample(sub_ntrts), length.out = sub_nunits),
"systematic" = ,
"systematic-fastest" = rep(1:sub_ntrts, length.out = sub_nunits),
"systematic-slowest" = sort(rep(1:sub_ntrts, length.out = sub_nunits)),
"systematic-random" = ,
"systematic-random-fastest" = rep(sample(sub_ntrts), length.out = sub_nunits),
"systematic-random-slowest" = sort(rep(sample(sub_ntrts), length.out = sub_nunits)),
"random" = {
if(is_empty(constrain[[unit_nm]])) {
sample(rep(sample(sub_ntrts), length.out = sub_nunits))
Expand All @@ -104,8 +108,12 @@ assign_trts <- function(.edibble, order = "random", seed = NULL, constrain = nes
} else {
ntrts <- nrow(trts_df)
permutation <- switch(order[igroup],
"systematic" = rep(1:ntrts, length.out = nunits),
"systematic-random" = rep(sample(ntrts), length.out = nunits),
"systematic" = ,
"systematic-fastest" = rep(1:ntrts, length.out = nunits),
"systematic-slowest" = sort(rep(1:ntrts, length.out = nunits)),
"systematic-random" = ,
"systematic-random-fastest" = rep(sample(ntrts), length.out = nunits),
"systematic-random-slowest" = sort(rep(sample(ntrts), length.out = nunits)),
"random" = {
if(is_empty(constrain[[unit_nm]])) {
sample(rep(sample(ntrts), length.out = nunits))
Expand Down

0 comments on commit 9f6b3ce

Please sign in to comment.