The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

The permutations package has a print method which includes a number of user-configurable options which are illustrated and motivated here.

Permutations have two natural representations: word form and cycle form. Internally, the package coerces a permutation from one form to another depending on what operations one does with it. Group-theoretic products and inverses are carried out more easily in word form, while powers are more easily done using cycle form.

Partly as a result of a perceptive comment from a journal reviewer, the package coerces to cycle form for printing as this is generally more comprehensible than word form. However, the package includes functions print_word() and print_cycle() which can be used explicitly to print in either word form or cycle form as desired:

set.seed(0)
x <- rperm(r=9)
print_word(x)
#>      {1} {2} {3} {4} {5} {6} {7} {8} {9}
#> [1]  9   4   7   1   2   .   3   .   5  
#> [2]  2   3   8   1   .   .   9   7   4  
#> [3]  7   1   9   5   6   8   4   2   3  
#> [4]  5   .   8   6   1   4   3   9   7  
#> [5]  3   6   2   7   4   5   8   9   1  
#> [6]  7   6   1   .   9   3   2   .   5  
#> [7]  3   .   6   7   8   1   5   9   4  
#> [8]  6   1   .   7   4   2   9   .   5  
#> [9]  4   5   1   7   9   3   6   .   2  
#> [10] 6   5   4   7   1   8   9   3   2
print_cycle(x)
#>  [1] (19524)(37)    (1238794)      (1745682)(39)  (15)(3897)(46) (132654789)   
#>  [6] (17263)(59)    (136)(47589)   (162)(4795)    (14763)(259)   (168347925)

It is a matter of taste which one is preferable. For the example above, the majority of the symbols are moved: elements that map to themselves are shown with a dot in the word form, and these are in a minority. However, the difference between word form and cycle form becomes more pronounced if only a small number of elements move:

x <- rperm(r=9,moved=3)
print_word(x)
#>      {1} {2} {3} {4} {5} {6} {7} {8} {9}
#> [1]  7   .   .   .   .   .   9   .   1  
#> [2]  .   9   2   .   .   .   .   .   3  
#> [3]  .   .   .   .   .   .   .   .   .  
#> [4]  3   .   1   .   .   .   .   .   .  
#> [5]  .   8   .   .   2   .   .   5   .  
#> [6]  .   .   .   6   .   4   .   .   .  
#> [7]  .   .   .   .   .   .   .   .   .  
#> [8]  .   .   .   8   .   .   .   4   .  
#> [9]  6   .   1   .   .   3   .   .   .  
#> [10] .   .   .   9   .   .   .   .   4
print_cycle(x)
#>  [1] (179) (293) ()    (13)  (285) (46)  ()    (48)  (163) (49)

Above we see the cycle form is arguably more compact.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.