Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.
This repository was archived by the owner on Mar 17, 2026. It is now read-only.

sample function in shuffle_within_groups behaves differently if length of input is 1 #2

@ctanes

Description

@ctanes

sample(8) for example would return sample(1:8) and not 8.

Can be fixed with
shuffle_within_groups <- function(x,g) {
ave(x, g, FUN = function(a) if(length(a)>1) sample(a) else a)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions