Warning for set / := when numToDo > nrow(x)?

Open
#3,557 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start at the data.table set/:= entry point and review the follow-up issues #2837, #1885, and #3460 for the existing assignment behavior. Reproduce the supplied c(1, 1) example with length(i) greater than nrow(x); done means this case produces the agreed warning without running duplicated unnecessarily.

Written by the indexing model from the issue text.

Description

by-reference

Follow-up to #2837 inspired by #1885 / #3460

We decided running duplicated every time we run set/:= to help protect against duplicated assignment is overkill & an efficiency killer.

However, when length(i) > nrow(x), there's no need to run duplicated -- there's guaranteed to be at least one duplicate in i (Pigeonhole):

DT = data.table(a = 1L)
DT[c(1, 1), a := 2:3]

We could warn in this case?

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.