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

Breaking change omitted from NEWS: spread(<data.table>) no longer inherits from data.table #1473

Open
MichaelChirico opened this issue Jan 24, 2023 · 3 comments
Labels
bug an unexpected problem or unintended behavior documentation

Comments

@MichaelChirico
Copy link
Contributor

We have some code broken by the update to tidyr 1.3.0 and I don't see the issue mentioned in NEWS so I'm not sure if it's intentional.

I can re-use the example from ?spread to demonstrate:

stocks <- tibble(
  time = as.Date("2009-01-01") + 0:9,
  X = rnorm(10, 0, 1),
  Y = rnorm(10, 0, 2),
  Z = rnorm(10, 0, 4)
)
stocksm <- stocks %>% gather(stock, price, -time)

# <not in ?spread>
data.table::setDT(stocksm)

stocksm %>% spread(stock, price) %>% inherits("data.table")
## ON 1.3.0
# [1] FALSE
## ON 1.2.1
# [1] TRUE

This breaks use cases that e.g. proceed to use [ on the spread() output and assume data.table syntax applies:

# works on 1.2.1, broken on 1.3.0
spread(stocksm, stock, price)[order(X)]
@hadley hadley added the bug an unexpected problem or unintended behavior label Nov 1, 2023
@hadley
Copy link
Member

hadley commented Nov 1, 2023

Do you have any sense of whether it's worth fixing this? By the time we get a release out, I'm worried that most people will have adapted so that the net effect will be more pain.

@MichaelChirico
Copy link
Contributor Author

I don't think a code fix is needed, but a NEWS entry citing this as a potential breaking change still makes sense to me.

@hadley
Copy link
Member

hadley commented Nov 2, 2023

Makes sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior documentation
Projects
None yet
Development

No branches or pull requests

2 participants