# List data types for permute
methods("permute")
# Permute matrix
m <- matrix(rnorm(10), 5, 2, dimnames = list(1:5, LETTERS[1:2]))
m
# Permute rows and columns
o <- ser_permutation(5:1, 2:1)
o
permute(m, o)
## permute only columns
permute(m, o, margin = 2)
## permute using PCA seriation
permute(m, "PCA")
## permute only rows using PCA
permute(m, o, margin = 1)
# Permute data.frames
df <- as.data.frame(m)
permute(df, o)
# Permute objects in a dist object
d <- dist(m)
d
permute(d, c(3, 2, 1, 4, 5))
permute(d, "Spectral")
# Permute a list
l <- list(a = 1:5, b = letters[1:3], c = 0)
l
permute(l, c(2, 3, 1))
# Permute a dendrogram
hc <- hclust(d)
plot(hc)
plot(permute(hc, 5:1))
Run the code above in your browser using DataLab