Rdatatable / Rdatatable/data.table
[R-Forge #2793] Allow subsets of LHS of `:=`
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Description
Submitted by: Eduard Antonyan; Assigned to: Eduard Antonyan; R-Forge link
Allow the following syntax:
dt = data.table(a = c(1,1,2,2), b = c(1,2,1,2))
dt[, a[b < 2] := 0]
This is possible to accomplish now using ifelse:
dt[, a := ifelse(b < 2, 0L, a)]
but that's much slower than what potentially could be, because ifelse has to construct vectors and assign values for both b < 2 and b >= 2.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the existing data.table := assignment implementation and the syntax shown in the issue. Investigate how subset expressions on the left-hand side are parsed and assigned. Done means supporting dt[, a[b < 2] := 0] with selective assignment while preserving the existing := behavior and performance motivation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100