r-spatial / r-spatial/s2

duplicated/anyDuplicated is not supported?

Open
#302 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
81
Forks
19
Avg merge
20h 25m
Merged PRs (30d)
3

Description

I guess this is a case of 64 bit int and NA handling?

library(s2)
cells <- s2_cells_at_level(5)  
any(duplicated(cells))              # TRUE  (wrong)
length(unique(cells))               # 6144  (right)
anyDuplicated(as.character(cells))  # 0     (right)


which(is.nan(unclass(cells)))
# [1] 4606 6142

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied s2_cells_at_level(5) example, then trace how duplicated(), unique(), and anyDuplicated() handle s2 cell vectors and the NaN values shown by unclass(cells). Done means duplicated(cells) no longer reports a false duplicate while unique(cells) and anyDuplicated(as.character(cells)) retain their correct results.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, r
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.