shift() could gain flatten= argument (a la split() ) governing the dimensions of the output list

Open
#6,036 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

The issue does not name implementation files or tests; start by reviewing the current shift() behavior and the discussion in #2932. Clarify the flatten= and give.names= output shapes, including their interaction with :=, then verify that named and unnamed inputs select the requested variables and lags as described.

Written by the indexing model from the issue text.

Description

enhancement

Follow-up to #2932.

It can be useful to expect shift(list(...), n) to have length(list(...)) outputs, with out[[ii]][[kk]] being the iith input shifted by n[kk]. (my guess is that's more useful than the transposed output like out[[kk]][[ii]]).

The current output (which would be flatten=TRUE by default) plays better with := (https://github.com/Rdatatable/data.table/issues/2932#issuecomment-396842139), but the proposed flatten=FALSE is better suited to more general programming.

Further, with give.names=TRUE, we should get out[[NAME_ii]][[CHAR_kk]] able to select vars+lags with strings.

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.