scramble_within_groups: scramble_within_groups function

View source: R/scramble_within_groups.R

scramble_within_groupsR Documentation

scramble_within_groups function

Description

Permutes the rows of a dataframe within groups.

Usage

scramble_within_groups(data, group_index)

Arguments

data

: A dataframe. One column is a categorical variable indicating group.

group_index

: Column index of the variable indicating group.

Value

: A dataframe with permuted rows. Rows are only permuted within groups. Permutations are done via sampling with replacement.

Examples

my_data <- data.frame(
Col1 = c(1, 2, 3, 4, 5, 6),
Col2 = c("A", "B", "A", "B", "C", "C"))
scramble_within_groups(my_data)

Anthony-Kwong/birdsong.tools documentation built on April 14, 2023, 9:50 a.m.