Skip to contents

Extract Duplicate Records

Usage

extract_duplicate_records(dataset, by_vars)

Arguments

dataset

A data frame

by_vars

A list of variables created using exprs() identifying groups of records in which to look for duplicates

Value

A data.frame of duplicate records within dataset

See also

Examples

data(admiral_adsl)

# Duplicate the first record
adsl <- rbind(admiral_adsl[1L, ], admiral_adsl)

extract_duplicate_records(adsl, exprs(USUBJID))
#> # A tibble: 2 x 50
#>   USUBJID  STUDYID  SUBJID RFSTDTC  RFENDTC  RFXSTDTC RFXENDTC RFICDTC RFPENDTC 
#>   <chr>    <chr>    <chr>  <chr>    <chr>    <chr>    <chr>    <chr>   <chr>    
#> 1 01-701-… CDISCPI… 1015   2014-01… 2014-07… 2014-01… 2014-07… NA      2014-07-…
#> 2 01-701-… CDISCPI… 1015   2014-01… 2014-07… 2014-01… 2014-07… NA      2014-07-…
#> # … with 41 more variables: DTHDTC <chr>, DTHFL <chr>, SITEID <chr>, AGE <dbl>,
#> #   AGEU <chr>, SEX <chr>, RACE <chr>, ETHNIC <chr>, ARMCD <chr>, ARM <chr>,
#> #   ACTARMCD <chr>, ACTARM <chr>, COUNTRY <chr>, DMDTC <chr>, DMDY <dbl>,
#> #   TRT01P <chr>, TRT01A <chr>, TRTSDTM <dttm>, TRTSTMF <chr>, TRTEDTM <dttm>,
#> #   TRTETMF <chr>, TRTSDT <date>, TRTEDT <date>, TRTDURD <dbl>, SCRFDT <date>,
#> #   EOSDT <date>, EOSSTT <chr>, FRVDT <date>, RANDDT <date>, DTHDT <date>,
#> #   DTHADY <dbl>, LDDTHELD <dbl>, LSTALVDT <date>, AGEGR1 <fct>, SAFFL <chr>,
#> #   RACEGR1 <chr>, REGION1 <chr>, LDDTHGR1 <chr>, DTH30FL <chr>,
#> #   DTHA30FL <chr>, DTHB30FL <chr>