Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rperm

Draw a Random Permutation Vector with Exchangeability Constraints


Description

Draws a random permutation on 1:length(exchange.list) such that no two elements whose corresponding exchange.list values are different are interchanged.

Usage

rperm(exchange.list)

Arguments

exchange.list

A vector such that the permutation vector may exchange the ith and jth positions iff exchange.list[i]==exchange.list[j]

Details

rperm draws random permutation vectors given the constraints of exchangeability described above. Thus, rperm(c(0,0,0,0)) returns a random permutation of four elements in which all exchanges are allowed, while rperm(c(1,1,"a","a") (or similar) returns a random permutation of four elements in which only the first/second and third/fourth elements may be exchanged. This turns out to be quite useful for searching permutation spaces with exchangeability constraints (e.g., for structural distance estimation).

Value

A random permutation vector satisfying the given constraints

Author(s)

Carter T. Butts buttsc@uci.edu

See Also

Examples

rperm(c(0,0,0,0))  #All elements may be exchanged
rperm(c(0,0,0,1))  #Fix the fourth element
rperm(c(0,0,1,1))  #Allow {1,2} and {3,4} to be swapped
rperm(c("a",4,"x",2))  #Fix all elements (the identity permutation)

sna

Tools for Social Network Analysis

v2.6
GPL (>= 2)
Authors
Carter T. Butts [aut, cre, cph]
Initial release
2020-10-5

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.