bit_sort_unique | R Documentation |
fast combination of sort
and unique
for integers
bit_sort_unique(
x,
decreasing = FALSE,
na.last = NA,
has.dup = TRUE,
range_na = NULL
)
x |
an integer vector |
decreasing |
|
na.last |
|
has.dup |
TRUE (the default) assumes that |
range_na |
|
determines the range of the integers and checks if the density justifies use
of a bit vector; if yes, creates the result using a bit vector; if no, falls back to sort(unique())
a sorted unique integer vector
sort
, unique
,
bit_sort
, bit_unique
bit_sort_unique(c(2L,1L,NA,NA,1L,2L))
bit_sort_unique(c(2L,1L,NA,NA,1L,2L), na.last=FALSE)
bit_sort_unique(c(2L,1L,NA,NA,1L,2L), na.last=TRUE)
bit_sort_unique(c(2L,1L,NA,NA,1L,2L), decreasing = TRUE)
bit_sort_unique(c(2L,1L,NA,NA,1L,2L), decreasing = TRUE, na.last=FALSE)
bit_sort_unique(c(2L,1L,NA,NA,1L,2L), decreasing = TRUE, na.last=TRUE)
## Not run:
x <- sample(1e7, replace=TRUE)
system.time(bit_sort_unique(x))
system.time(sort(unique(x)))
x <- sample(1e7)
system.time(bit_sort_unique(x))
system.time(sort(x))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.