how do you test whether a vector contains repetitive elements in R?
Proof (a) Suppose that 0 and 0 are both zero vectors in V . Then x + 0 = x and x + 0 = x, for all x ∈ V . Therefore, 0 = 0 + 0, as 0 is a zero vector, = 0 + 0 , by commutativity, = 0, as 0 is a zero vector. Hence, 0 = 0 , showing that the zero vector is unique.
No, it is only bad if the source data is particularly large and unlikely to have any duplicates.
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
Also try rle(x)
to find the lengths of runs of identical values in x
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With