permute: Generate all permutations of a vector

View source: R/permute.R

permuteR Documentation

Generate all permutations of a vector

Description

This function generates all possible permutations of the elements in a given vector x. The result is returned as a matrix, where each row represents a unique permutation of the input vector.

Usage

permute(x)

Arguments

x

A vector of elements to permute. The elements can be of any type, but they should be unique for meaningful permutations.

Value

A matrix where each row is a unique permutation of the input vector x.

Author(s)

Michal Burda

See Also

utils::combn() for combinations of elements.

Examples

permute(c(1, 2, 3))
permute(c("a", "b", "c"))


nuggets documentation built on Aug. 20, 2026, 5:07 p.m.