permutations (version 1.0-0)

valid: Functions to validate permutations

Description

Functions to validate permutation objects.

Function singleword.valid() takes an integer vector and checks that it is a permutation of seq_len(max(x)).

Function cycle.valid() takes a cyclist and checks for disjoint cycles of strictly positive integers with no repeats.

Usage

singleword_valid(w) cyclist_valid(x)

Arguments

x
In function cycle_valid(), a cyclist
w
In function singleword_valid(), an integer vector

Value

Returns either TRUE, or stops with an informative error message

See Also

cyclist

Examples

Run this code

singleword_valid(sample(1:9))

## Not run: 
# singleword_valid(c(5,6,3,9,7,8,2,1))   # returns an error (no '4')
# singleword_valid(c(5,6,3,4,9,7,8,2,1)) # returns an error (not integer)
# ## End(Not run)

cyclist_valid(list(c(1,8,2),c(3,6))) # should be TRUE

## Not run: 
# cyclist_valid(list(c(1,8,2),c(8,6))) # returns an error ('8' is repeated)
# ## End(Not run)

Run the code above in your browser using DataLab