which_equal, which_in

Open
#3,663 2 comments 1 reaction 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
c, r
Domain
data, performance

Research direction

Start with src/utils.c around lines 66-69 and trace the implementations of dt[expr, which=TRUE] and set(dt, which(dt$col==val), "col", new_val). Determine how which_eq could serve these paths without materialising an intermediate logical vector; done means both call patterns return the expected indices and preserve their current behavior.

Written by the indexing model from the issue text.

Description

internals

There is a space for improvement when it comes to dt[expr, which=TRUE] and similar calls like set(dt, which(dt$col==val), "col", new_val).
Function available in https://github.com/Rdatatable/data.table/blob/b9265841edecc6d8d3d0e5428f0bc622a147ba16/src/utils.c#L66-L69 which_eq could be used for that purpose. As a result we can obtain which indices without materialising intermediate logical vector that normally needs to be supplied to which function. Logical vectors are expensive in R as they are basically integers.
It would also be a step towards #852

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.