Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to shift cause backwards naming issues #3832

Closed
daynefiler opened this issue Sep 6, 2019 · 1 comment · Fixed by #3833
Closed

Changes to shift cause backwards naming issues #3832

daynefiler opened this issue Sep 6, 2019 · 1 comment · Fixed by #3833
Milestone

Comments

@daynefiler
Copy link

@daynefiler daynefiler commented Sep 6, 2019

This is totally related to #3223 and the new shift behavior from #1708. I just want to point out that the new behavior caused some old code to break due to naming inconsistencies. I think the best option here is to adapt to using type = "shift" with negative values, but it definitely threw me for a loop.

# Minimal reproducible example

dat <- data.table(a = 1:3, b = 2:4)

## Using data.table 1.12.2
dat[ , data.table::shift(.SD, 0:1, give.names = TRUE, type = "lead")]
#    a_lag_0 a_lead_1 b_lag_0 b_lead_1
# 1:       1        2       2        3
# 2:       2        3       3        4
# 3:       3       NA       4       NA

## Using data.table 1.11.8
dat[ , data.table::shift(.SD, 0:1, give.names = TRUE, type = "lead")]
#    a_lead_0 a_lead_1 b_lead_0 b_lead_1
# 1:        1        2        2        3
# 2:        2        3        3        4
# 3:        3       NA        4       NA

# Output of sessionInfo()

R-3.5.1; data.table 1.12.2 & 1.11.8

@MichaelChirico
Copy link
Member

@MichaelChirico MichaelChirico commented Sep 6, 2019

@jangorecki it's this line of code:

6e60d7b

with specific comment:

lead_0 should be named lag_0 for consistency

I think that makes more sense if there are mixed positive & negative n, seems natural if all(n>=0) to use only one word, thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants