Learn R Programming

PerMallows (version 1.14)

swap: Swap two items of a permutation

Description

Given a permutation and two position, swap both positions

Usage

swap(perm, i, j)

Value

The permutation in the input in which the two speicfied items have been swapped

Arguments

perm

a permutation

i

position of the permutation

j

position of the permutation

Examples

Run this code
swap(c(1,2,3,4,5),2,5)

Run the code above in your browser using DataLab