Print methods for permutation objects with matrix-like printing for words and bracket notation for cycle objects.
1 2 3 4 5
Object of class
Boolean, with default
Further arguments (currently ignored)
Printing of word objects is controlled by
options("print_word_as_cycle"). The default behaviour is to
coerce a word to cycle form and print that, with a notice that the
object itself was coerced from word.
FALSE, then objects
of class word are printed as a matrix with rows being the permutations
and fixed points indicated with a dot.
as.character_cyclist() is an internal function used by
print.cycle(), and is not really designed for the end-user. It
takes a cyclist and returns a character string.
Returns its argument invisibly, after printing it.
Robin K. S. Hankin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# generate a permutation in *word* form: x <- rperm(4,9) # default behaviour is to print in cycle form irregardless: x # change default using options(): options(print_word_as_cycle=FALSE) # objects in word form now printed using matrix notation: x # printing of cycle form objects not altered: as.cycle(x) # restore default: options(print_word_as_cycle=TRUE) as.character_cyclist(list(1:4,10:11,20:33)) # x a cyclist; as.character_cyclist(list(c(1,5,4),c(2,2))) # does not check for consistency as.character_cyclist(list(c(1,5,4),c(2,9)),comma=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.