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 76
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/colwise-distinct.R
\name{distinct_all}
\alias{distinct_all}
\alias{distinct_at}
\alias{distinct_if}
\title{Select distinct rows by a selection of variables}
\usage{
distinct_all(.tbl, .funs = list(), ..., .keep_all = FALSE)
distinct_at(.tbl, .vars, .funs = list(), ..., .keep_all = FALSE)
distinct_if(.tbl, .predicate, .funs = list(), ..., .keep_all = FALSE)
}
\arguments{
\item{.tbl}{A \code{tbl} object.}
\item{.funs}{A function \code{fun}, a quosure style lambda \code{~ fun(.)} or a list of either form.}
\item{...}{Additional arguments for the function calls in
\code{.funs}. These are evaluated only once, with \link[rlang:dyn-dots]{tidy dots} support.}
\item{.keep_all}{If \code{TRUE}, keep all variables in \code{.data}.
If a combination of \code{...} is not distinct, this keeps the
first row of values.}
\item{.vars}{A list of columns generated by \code{\link[=vars]{vars()}},
a character vector of column names, a numeric vector of column
positions, or \code{NULL}.}
\item{.predicate}{A predicate function to be applied to the columns
or a logical vector. The variables for which \code{.predicate} is or
returns \code{TRUE} are selected. This argument is passed to
\code{\link[rlang:as_function]{rlang::as_function()}} and thus supports quosure-style lambda
functions and strings representing function names.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}
Scoped verbs (\verb{_if}, \verb{_at}, \verb{_all}) have been superseded by the use of
\code{\link[=pick]{pick()}} or \code{\link[=across]{across()}} in an existing verb. See \code{vignette("colwise")} for
details.
These \link{scoped} variants of \code{\link[=distinct]{distinct()}} extract distinct rows by a
selection of variables. Like \code{distinct()}, you can modify the
variables before ordering with the \code{.funs} argument.
}
\section{Grouping variables}{
The grouping variables that are part of the selection are taken
into account to determine distinct rows.
}
\examples{
df <- tibble(x = rep(2:5, each = 2) / 2, y = rep(2:3, each = 4) / 2)
distinct_all(df)
# ->
distinct(df, pick(everything()))
distinct_at(df, vars(x,y))
# ->
distinct(df, pick(x, y))
distinct_if(df, is.numeric)
# ->
distinct(df, pick(where(is.numeric)))
# You can supply a function that will be applied before extracting the distinct values
# The variables of the sorted tibble keep their original values.
distinct_all(df, round)
# ->
distinct(df, across(everything(), round))
}
\keyword{internal}
|