get_duplicated_rows | R Documentation |
This helper function extracts the row number (or first column value) in a tibble having identical values for all columns. This function can be used either on the whole columns or excluding the first column (id) (which can be useful to identify repeated observation across different ids)
get_duplicated_rows(tbl, id_col = NULL)
tbl |
R object(dataframe or tibble) of the input tibble |
id_col |
A character string specifying the column to ignore in identification of repeated observations. If NULL (by default), all of the columns will be taken in account for repeated observation identification. The row number will be used to identify those observations. |
A tibble indicating which row which values is the same in the tibble
{
# the row numbers are returned to identify which observations have repeated
# values
library(dplyr)
get_duplicated_rows(tbl = bind_rows( tbl = mtcars, mtcars[1,]))
get_duplicated_rows(
tbl = bind_rows(mtcars,mtcars[1,]) %>%
add_index() %>%
mutate(index = paste0('obs_',index)),
id_col = 'index')
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.