Learn R Programming

PerMallows (version 1.14)

is.permutation: Check if its argument is a permutation

Description

This function tests if the given argument is a permutation of the first n natural integers (excluding 0)

Usage

is.permutation(perm)

Value

TRUE iff perm is a valid permutation (or a matrix of valid permutations)

Arguments

perm

a vector (or a bidimensional matrix)

Examples

Run this code
is.permutation(c(3,1,2,4))
is.permutation(c(6,1,2,3))
is.permutation(matrix(c(1,2,3, 4,1,4,3,2,1,2,4,3), nrow = 3, ncol = 4, byrow = TRUE))

Run the code above in your browser using DataLab