Learn R Programming

permutations (version 1.1-9-1)

Extract: Extract or Replace elements of permutation vectors

Description

Methods for "[" and "[<-", i.e., extraction or subsetting of permutation vectors.

Arguments

Value

Extraction and methods return an onion or onionmat. Replacement methods return an object of the same class as the right hand side.

Author

Robin K. S. Hankin

Details

Extraction and replacement for word form uses array-based indexing. Cycle form uses list-based indexing and is thus less flexible.

Examples

Run this code

(a <- rperm(9))
a[1:3]
a[5:7] <- id  # word form: multiple replacements allowed.
a

x <- as.cycle(rperm(9))
x
x[5] <- x[4] * x[6]  # cycle form: replacement takes only a single index.
x

Run the code above in your browser using DataLab