Description Usage Arguments Details Value Author(s) Examples
Efficiently generate truly unique and random permutations of binary data in R.
1 | permute(original, number_permutations)
|
original |
an integer (0/1 only) or logical vector representing the statuses of the true observations. |
number_permutations |
integer; desired number of permutations to find. |
This function uses C++ bitsets to decrease memory load and
random_shuffle
to increase speed. It is capable of generating
1,000,000 unique permutations of a 1000 observation binary vector in
around 30 seconds.
If you are getting errors while using this method it is likely because this method has a C++ implementation. Check to make sure that you have the necessary tools to compile C++ code.
A 0/1 matrix with number_permutations
rows and
length(original)
columns. If there are fewer possible permutations
than are requested, will return as many as possible.
PJ Tatlow, Samantha Jensen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | example_states <- c(0,0,0,0,1,1,1,1)
permute(example_states, 34)
example_states <- c(rep(1, 500), rep(0,500))
permute(example_states, 1000)
#TIMING AND MEMORY USAGE EXAMPLES
library(R.utils) # for timing
library(profmem) # for memory usage information
ptm <- proc.time()
permute(example_states, 1000)
print(proc.time() - ptm)
print(total(profmem(permute(example_states, 1000))))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.