Shuffle the rows in a column
shuffle_group(dat, col_name)
Arguments
- dat
a data frame containing col_name
- col_name
column name to shuffle
Value
dat
with the rows of col_name
shuffled
Examples
set.seed(123)
df <- dplyr::tibble(
condition = c("a", "a", "b", "b"),
AUC = c(.2, 0.3, 0.8, 0.9)
)
shuffle_group(df, "condition")
#> # A tibble: 4 × 2
#> condition AUC
#> <chr> <dbl>
#> 1 b 0.2
#> 2 b 0.3
#> 3 a 0.8
#> 4 a 0.9