Using incomparables argument within duplicated() in R

前端 未结 1 1941
甜味超标
甜味超标 2021-01-23 16:39

I have the following matrix:

structure(c(NA, NA, \"2, 3, 5, 7\", \"1, 3, 5, 7\", NA, \"1, 3, 7\", 
\"2, 3, 5, 8\", \"2, 3, 5, 7\", \"1, 5, 7, 8\", \"1, 2, 3, 7,          


        
1条回答
  •  无人及你
    2021-01-23 16:58

    The help page help(duplicated) says:

    incomparables
    a vector of values that cannot be compared. FALSE is a special value, meaning that all values can be compared, and may be the only value accepted for methods other than the default. It will be coerced internally to the same type as x.

    So incomparables = NA seems to not work. However, you can get the effect that you are looking for with:

    duplicated(cand, MARGIN = 0) & !is.na(cand)
    

    0 讨论(0)
提交回复
热议问题