R/04-check_table_values.R
get_duplicated_cols.Rd
This helper function extracts the names of the columns in a tibble having identical values for all observations.
get_duplicated_cols(tbl)
R object(dataframe or tibble) of the input tibble
A tibble indicating which columns which values is the same in the tibble
{
library(dplyr)
tbl <-
mtcars %>%
mutate(
cyl_2 = cyl,
cyl_3 = cyl,
mpg_2 = mpg)
get_duplicated_cols(tbl)
}
#> # A tibble: 5 × 2
#> condition col_name
#> <chr> <chr>
#> 1 Possible duplicated columns: mpg ; mpg_2 mpg
#> 2 Possible duplicated columns: mpg ; mpg_2 mpg_2
#> 3 Possible duplicated columns: cyl ; cyl_2 ; cyl_3 cyl
#> 4 Possible duplicated columns: cyl ; cyl_2 ; cyl_3 cyl_2
#> 5 Possible duplicated columns: cyl ; cyl_2 ; cyl_3 cyl_3