duplicated_cols: Names of Duplicate Columns

Description Usage Examples

View source: R/qa.R

Description

Return the column names in a dataframe that contain duplicate values of another column.

Usage

1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(tidyverse)
test_data <- 
        tibble(
                Group = sample(c("Apple", "Pear"), size = 10, replace = TRUE),
                A     = sample(c(NA_integer_, 1:3), size = 10, replace = TRUE),
                B     = sample(c(NA_integer_, 4:6), size = 10, replace = TRUE),
                C     = sample(c(NA_real_, seq(from = 6.01, to = 6.09, by = 0.01)), size = 10, replace = TRUE),
                D     = sample(c(NA, TRUE, FALSE), size = 10, replace = TRUE)
        ) %>%
        dplyr::mutate(E = B)
        

duplicated_cols(test_data)

test_data %>%
        select(-all_of(duplicated_cols(test_data)))

meerapatelmd/rubix documentation built on Sept. 5, 2021, 8:30 p.m.