View source: R/count_duplicates.R
count_duplicates | R Documentation |
Given a data frame, this will retun a data frame of the duplicate rows with a column for the number of times that it appears in the data.
Very similar and not as preferred to the get_dupes
function in Sam Firke's
janitor
package. I did borrow some code from that one to deal with cases
when variable are specified and when they are not (variables are arguments to
...
).
count_duplicates(data, ...)
data |
A data frame or tibble |
... |
Unquoted variable names to search for duplicates. |
Returns a data.frame (actually a tbl_df
) with the full records where
the specified variables have duplicated values, as well as a variable
dupe_count
showing the number of rows sharing that combination of
duplicated values.
https://cran.r-project.org/web/packages/janitor/janitor.pdf
https://github.com/sfirke/janitor/blob/master/R/get_dupes.R
library(dplyr)
(DF <- data.frame(replicate(sequence(1:3), n = 4)))
count_duplicates(DF)
count_duplicates(DF, X2, X3)
# Pipeable also
DF %>%
count_duplicates(.)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.