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).