add fsetdiff(), fintersect(), funion() supports for vectors

Open
#3,752 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Start from the existing fsetdiff(), fintersect(), and funion() implementations for data.table objects, then compare their behavior with the Date vector examples in this issue. Determine how vector inputs should preserve attributes while performing the set operations. Done means the three functions support vectors without stripping attributes, with tests covering the demonstrated Date cases.

Written by the indexing model from the issue text.

Description

feature request

Hi,

data.table has already implemented fantastic fsetdiff(), fintersect(), funion() for data.table objects. I would like to proposal their supports on vectors as well. The reason is the equivalent functions in base R will stripe off all the attributes and is bad for Date (or any other inputs with attributes).

vec_date1 <- as.Date(c('1999-01-01', '1999-01-02'))
vec_date2 <- as.Date(c('1999-01-02', '1999-01-03'))
intersect(vec_date1, vec_date2)
#> [1] 10593
setdiff(vec_date1, vec_date2)
#> [1] 10592
union(vec_date1, vec_date2)
#> [1] 10592 10593 10594

Created on 2019-08-09 by the reprex package (v0.2.1)

Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

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.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.