1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bitsort.R
\name{bit_unidup}
\alias{bit_unidup}
\alias{bit_unique}
\alias{bit_duplicated}
\alias{bit_anyDuplicated}
\alias{bit_sumDuplicated}
\title{bit unique and duplicated}
\usage{
bit_unique(x, na.rm = NA, range_na = NULL)
bit_duplicated(x, na.rm = NA, range_na = NULL, retFUN = as.bit)
bit_anyDuplicated(x, na.rm = NA, range_na = NULL)
bit_sumDuplicated(x, na.rm = NA, range_na = NULL)
}
\arguments{
\item{x}{an integer vector}
\item{na.rm}{\code{NA} treats NAs like other integers, \code{TRUE} treats
\emph{all} NAs as duplicates, \code{FALSE} treats \emph{no} NAs as
duplicates}
\item{range_na}{\code{NULL} calls \code{\link{range_na}}, optionally the result of \code{\link{range_na}} can be given here to avoid calling it again}
\item{retFUN}{a function that coerces \code{\link{bit}} and \code{\link{logical}} vectors}
}
\value{
\code{bit_unique} returns a vector of unique integers, \cr
\code{bit_duplicated} returns a boolean vector coerced to \code{retFUN}, \cr
\code{bit_anyDuplicated} returns the position of the first duplicate (or zero if no duplicates) \cr
\code{bit_sumDuplicated} returns the number of duplicated values (as.integer)
}
\description{
Fast versions of \code{\link{unique}}, \code{\link{duplicated}} ,
\code{\link{anyDuplicated}} and \code{sum(duplicated(x))} for integers.
}
\details{
determines the range of the integers and checks if the density justifies use
of a bit vector; if yes, uses a bit vector for finding duplicates; if no,
falls back to \code{\link{unique}}, \code{\link{duplicated}}, \code{\link{anyDuplicated}} and \code{sum(duplicated(x))}
}
\section{Functions}{
\itemize{
\item \code{bit_unique}: extracts unique elements
\item \code{bit_duplicated}: determines duplicate elements
\item \code{bit_anyDuplicated}: checks for existence of duplicate elements
\item \code{bit_sumDuplicated}: counts duplicate elements
}}
\examples{
bit_unique(c(2L,1L,NA,NA,1L,2L))
bit_unique(c(2L,1L,NA,NA,1L,2L), na.rm=FALSE)
bit_unique(c(2L,1L,NA,NA,1L,2L), na.rm=TRUE)
bit_duplicated(c(2L,1L,NA,NA,1L,2L))
bit_duplicated(c(2L,1L,NA,NA,1L,2L), na.rm=FALSE)
bit_duplicated(c(2L,1L,NA,NA,1L,2L), na.rm=TRUE)
bit_anyDuplicated(c(2L,1L,NA,NA,1L,2L))
bit_anyDuplicated(c(2L,1L,NA,NA,1L,2L), na.rm=FALSE)
bit_anyDuplicated(c(2L,1L,NA,NA,1L,2L), na.rm=TRUE)
bit_sumDuplicated(c(2L,1L,NA,NA,1L,2L))
bit_sumDuplicated(c(2L,1L,NA,NA,1L,2L), na.rm=FALSE)
bit_sumDuplicated(c(2L,1L,NA,NA,1L,2L), na.rm=TRUE)
}
\seealso{
\code{\link{bit_sort_unique}}
}
|