0

I would like to extract duplicated strings from a list. As, the unique function does not work on non-numerical data, I used the stringi package with the stri_duplicated function to obtain logical values (TRUE or FALSE). I would like to extract the strings that are duplicated from the list (the strings for which stri_duplicated reports a TRUE).

Here a minimal example:

ex1 <- c("SE1", "SE2", "SE5", "SE2")
dupl <- stri_duplicated(ex1)

> dupl
[1] FALSE FALSE FALSE  TRUE

Many thanks in advance.

ABiologist
  • 43
  • 6

1 Answers1

-1

In base-R there is

duplicated(ex1)
[1] FALSE FALSE FALSE  TRUE

if you want to extract the duplicated items

ex1[duplicated(ex1)]
[1] "SE2"
Daniel O
  • 4,258
  • 6
  • 20
  • 1
    If the downvoter cares to comment why they think this is a poor answer, I would be happy to address it. – Daniel O Jul 14 '20 at 14:09