Return FALSE for duplicated NA values when using the function duplicated() Return FALSE for duplicated NA values when using the function duplicated() r r

Return FALSE for duplicated NA values when using the function duplicated()


You use the argument incomparables for the function duplicated like this :

> duplicated(c(NA,NA,NA,1,2,2))[1] FALSE  TRUE  TRUE FALSE FALSE  TRUE> duplicated(c(NA,NA,NA,1,2,2),incomparables=NA)[1] FALSE FALSE FALSE FALSE FALSE  TRUE

It determines the values that cannot be compared (in this case NA) and returns FALSE for those values. See also ?duplicated