Skip to content

shift better naming for negative n #3223

@jangorecki

Description

@jangorecki

as discussed in inline comments to #3166
now when shift accepts negative integers we can get column names like V1_lag_-1 / V1_lead_-1, they look awkward.

  • My suggestion is to use V1_shift_1 / V1_shift_-1 instead. This cannot be made without breaking change to current behavior, unless we introduce new type, just type="shift". Not much changes to code, and users who prefer to use only new interface (positive to lag, negative for lead) could switch to type="shift". Good to have it for 1.12.0 as we are releasing negative n feature there.

  • Additionally on docker tests we are getting - fixed in 76d4a62 - issue was that match.arg was using shell dependent quoting

Test 1963.8 didn't produce the correct error :
Expected: should be one of "lag" 
Observed: 'arg' should be one of “lag”, “lead” 

those are environments striped out from many R stuff that is by default active, like methods package.

test(1963.8, shift(DT$x, type = 'some_other_type'),
     error = 'should be one of "lag"')
  • fix invalid test 1963.4,, atomic vectors should not be named

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions