Closed taiawu closed 1 year ago
I think the fact that expand.grid(NULL, anything)
puts a NULL
in the data frame as a column is actually a bug in expand.grid()
. NULL
columns create a corrupt data frame, and the best thing vctrs can do about that is error, so there isn't anything we can do on our end.
Really that NULL
should have been removed from the result like in these other cases
vctrs:::unstructure(expand.grid(NULL))
#> list()
vctrs:::unstructure(expand.grid(1, NULL))
#> [[1]]
#> numeric(0)
vctrs:::unstructure(expand.grid(NULL, 1))
#> [[1]]
#> NULL
#>
#> [[2]]
#> numeric(0)
I've reported the problem to R-devel
dplyr::arrange()
fails when applied to the output ofexpand.grid()
if the first argument toexpand.grid()
isNULL
.base version 4.3.1 dplyr version 1.1.3 RStudio Version 2023.09.0+463 (2023.09.0+463)
Created on 2023-09-29 with reprex v2.0.2
Running
expand.grid(NULL, LETTERS)
in an R Notebook returns an error message, but it doesn't act like a typical error--it returns a data frame anyway, and the code continues to execute.I don't see this error message when I run the same line of code in the console, and it also isn't captured by
reprex::reprex()
.Result from
reprex::reprex()
withexpand.grid(NULL, LETTERS)
on the clipboard:Created on 2023-09-29 with reprex v2.0.2
Even in an R Notebook, I don't see the error if I assign the output of
expand.grid(NULL, LETTERS)
. The resulting object reproduces the original error message fromdplyr::arrange()
.Created on 2023-09-29 with reprex v2.0.2
Displaying / printing the assigned object appears to have the same error message behavior as
expand.grid(NULL, LETTERS)
Run in R Notebook chunk, copied associated output from console:
Other notes, for completion:
Created on 2023-09-29 with reprex v2.0.2