Search code examples
rvector

How to test whether a vector contains repetitive elements?


how do you test whether a vector contains repetitive elements in R?


Solution

  • I think I found the answer. Use duplicated() function:

    a=c(3,5,7,2,7,9)
    b=1:10
    any(duplicated(a)) #True
    any(duplicated(b)) #False