## cyclic group of order 4:
cayley(as.cycle(1:4)^(0:3))
## Klein group:
K4 <- as.cycle(c("()","(12)(34)","(13)(24)","(14)(23)"))
names(K4) <- c("00","01","10","11")
cayley(K4)
## S3, the symmetric group on 3 elements:
S3 <- as.cycle(c(
"()",
"(12)(35)(46)", "(13)(26)(45)",
"(14)(25)(36)", "(156)(243)", "(165)(234)"
))
names(S3) <- c("()","(ab)","(ac)","(bc)","(abc)","(acb)")
cayley(S3)
## Now an example from the onion package, the quaternion group:
if (FALSE) {
library(onion)
a <- c(H1,-H1,Hi,-Hi,Hj,-Hj,Hk,-Hk)
X <- word(sapply(1:8,function(k){sapply(1:8,function(l){which((a*a[k])[l]==a)})}))
cayley(X) # a bit verbose; rename the vector:
names(X) <- letters[1:8]
cayley(X) # more compact
}
Run the code above in your browser using DataLab