Learn R Programming

PerMallows (version 1.13)

swap: Swap two items of a permutation

Description

Given a permutation and two position, swap both positions

Usage

swap(perm, i, j)

Arguments

perm
a permutation
i
position of the permutation
j
position of the permutation

Value

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

Examples

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

Run the code above in your browser using DataLab