powered by
Permutes values of 'x' within each stratum. By default, rows with NA in 'x' or 'strata' are left unchanged to preserve alignment.
permute_within_strata(x, strata, seed = NULL, na_action = c("keep", "drop"))
x_star permuted within strata.
vector to permute.
factor-like vector defining strata.
optional seed for reproducibility.
how to handle NA rows: "keep" (default) keeps them fixed, "drop" removes them (returns shorter vector).
set.seed(123) x <- 1:10 strata <- rep(letters[1:2], each = 5) x_permuted <- permute_within_strata(x, strata, seed = 123)
Run the code above in your browser using DataLab