You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previous versions of dplyr would allow you to manipulate empty dataframes that had been constructed from empty matrices, e.g.
packageurl<-"https://cran.r-project.org/src/contrib/Archive/dplyr/dplyr_1.1.3.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
#> Installing package into 'C:/Users/edwar/Documents/R/win-library/4.1'#> (as 'lib' is unspecified)
packageVersion('dplyr')
#> [1] '1.1.3'
as.data.frame(matrix(nrow=0, ncol=0)) |>dplyr::slice(1)
#> data frame with 0 columns and 0 rows
In dplyr 1.1.4, this code causes an internal error:
packageurl<-"https://cran.r-project.org/src/contrib/dplyr_1.1.4.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
#> Installing package into 'C:/Users/edwar/Documents/R/win-library/4.1'#> (as 'lib' is unspecified)
packageVersion('dplyr')
#> [1] '1.1.4'
as.data.frame(matrix(nrow=0, ncol=0)) |>dplyr::slice(1)
#> Error: Internal error: `template` must have a `names` attribute.
Both versions are able to reliably manipulate empty dataframes that were not constructed from matrices (e.g. data.frame() |> dplyr::slice(1) works just fine).
The text was updated successfully, but these errors were encountered:
I think this may actually be a base R bug. I believe that all data.frames should have a names attribute. If there are 0 columns then it should be set to character(). The fact that that isn't the case here is odd.
names<- names(data)
if (is.null(names)) {
abort("Can't transform a data frame with `NULL` names.")
}
which would go nicely with our other names related checks there.
It did use names() in the past, but I switched to names2() here to supposedly fix this exact case. Supposedly not supporting NULL column names broke 2 packages and that was what I was out to fix, but that seems like a false alarm because current CRAN dplyr obviously already doesn't support NULL column names based on this issue. So the change above would just be giving a better error message for this invalid data frame. #4896
Previous versions of dplyr would allow you to manipulate empty dataframes that had been constructed from empty matrices, e.g.
In dplyr 1.1.4, this code causes an internal error:
Both versions are able to reliably manipulate empty dataframes that were not constructed from matrices (e.g.
data.frame() |> dplyr::slice(1)
works just fine).The text was updated successfully, but these errors were encountered: