forked from RobinHankin/permutations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
81 lines (59 loc) · 2.16 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
<!-- badges: start -->
[](https://travis-ci.org/RobinHankin/permutations)
[](https://cran.r-project.org/package=permutations)
[](http://www.rdocumentation.org/packages/permutations)
<!-- badges: end -->
# 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](https://CRAN.R-project.org) with:
```{r}
# install.packages("permutations") # uncomment this to use the package
library("permutations")
```
The package is maintained on
[github](https://github.com/RobinHankin/permutations).
# The ```permutations``` package in use
Random permutations on a finite set are given by the ```rperm()``` command:
```{r, echo=FALSE}
set.seed(0)
```
```{r rperm}
rperm(10,9)
```
The result is printed in cycle form but we can print in word form if we wish:
```{r wordformprint}
options(print_word_as_cycle=FALSE) # override default
as.word(rperm(10,9,3))
options(print_word_as_cycle=TRUE) # usually want to print a cycle irregardless
```
(A dot indicates a fixed point). The package uses arithmetic
operations ```*``` to combine permutations and ```^``` for
conjugation:
```{r arith}
(a <- as.word(c(4,2,3,1,5,7,6)))
(b <- as.cycle(1:4))
a*b
b*a
```
# 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.