MyNixOS website logo
Description

The Symmetric Group: Permutations of a Finite Set.

Manipulates invertible functions from a finite set to itself. Can transform from word form to cycle form and back. To cite the package in publications please use Hankin (2020) "Introducing the permutations R package", SoftwareX, volume 11 <doi:10.1016/j.softx.2020.100453>.

Group theory in R: the permutations package

CRAN_Status_Badge Codecov testcoverage

Overview

The permutations package provides R-centric functionality for working with permutations of a finite set. It includes group-theoretic composition of permutations and can transform from word form to cycle form and back.

Installation

You can install the released version of permutations from CRAN with:

# install.packages("permutations")  # uncomment this to use the package
library("permutations")
#> 
#> Attaching package: 'permutations'
#> The following object is masked from 'package:stats':
#> 
#>     cycle

The package is maintained on github.

The permutations package in use

Random permutations on a finite set are given by the rperm() command:

(x <- rperm(10, 9))
#>  [1] (19524)(37)    (1238794)      (1745682)(39)  (15)(3897)(46) (132654789)   
#>  [6] (17263)(59)    (136)(47589)   (162)(4795)    (14763)(259)   (168347925)   
#> [coerced from word form]

Above, object x is internally stored as a matrix (word form) but the result is printed in cycle form by default, as this is easier to understand. We can print in word form if we wish:

options(print_word_as_cycle = FALSE) # override default
as.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
options(print_word_as_cycle = TRUE) # restore default: we usually want to print a cycle irregardless

(A dot indicates a fixed point). The package uses arithmetic operations * to combine permutations and ^ for conjugation:

(a <- as.word(c(4, 2, 3, 1, 5, 7, 6)))
#> [1] (14)(67)
#> [coerced from word form]
(b <- as.cycle(1:4))
#> [1] (1234)
a * b
#> [1] (234)(67)
#> [coerced from word form]
b * a
#> [1] (123)(67)
#> [coerced from word form]

The megaminx

The megaminx is a dodecahedral puzzle with similar construction to the Rubik cube puzzle that has 50 movable pieces and 132 coloured stickers (“facets”). The permutations package includes functionality to simulate the megaminx and exhibits an 82-turn superflip. The vignette gives an extended discussion.

Metadata

Version

1.1-5

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows