randomize {nem} | R Documentation |
Return randomized binary network with the same density as the initial network. Loops are not assumed. The randomized network is asymmetric.
randomize(network)
network |
the binary network, of class |
##---- Should be DIRECTLY executable !! ---- ##-- ==> Define data, use random, ##-- or do help(data=index) for the standard data sets. ## The function is currently defined as randomize <- function(network){ random <- matrix(sample(network), nrow = nrow(network)) ndiag <- sum(diag(random)) diag(random) <- -1 random[sample(which(random == 0), replace = F, size = ndiag)] <- 1 diag(random) <- 0 return(random) }