Skip to content

Conversation

DavisVaughan
Copy link
Member

Closes #1252

Now that #1253 is merged, we can remove this slightly incorrect conditional code path for the zero column case (because it doesn't handle the zero row case right). But we still need to handle data.table's behavior with dt[character()] returning a zero row data table (see #1073), so we just convert data to a tibble early on to avoid this. We do this anyways eventually, so it doesn't affect any behavior.

We do this anyways later on before `vec_cbind()`ing, so it won't affect the output type.

The original hack is incorrect in the zero row data frame case, because `nrow` should be `0L` here, and `rows` should have zero rows.
@DavisVaughan DavisVaughan merged commit 7c0f97b into tidyverse:main Dec 3, 2021
@DavisVaughan DavisVaughan deleted the fix/zero-row-pivot-stability branch December 3, 2021 19:00
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 this pull request may close these issues.

pivot_wider() can result in >0 rows if given a 0 row data frame
1 participant