Discovered via a revdep conversation https://github.com/Thie1e/cutpointr/issues/22#issuecomment-521002505
Feels like nest(), with no nesting vars specified, on an ungrouped input, should produce some variation of the warning seen for unnamed elements of ....
library(tidyr)
packageVersion("tidyr")
#> [1] '0.8.99.9000'
nest(iris, Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species)
#> Warning: All elements of `...` must be named.
#> Did you want `data = c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species)`?
#> # A tibble: 1 x 1
#> data
#> <list<df[,5]>>
#> 1 [150 × 5]
nest(iris)
#> # A tibble: 1 x 1
#> data
#> <list<df[,5]>>
#> 1 [150 × 5]
Created on 2019-08-13 by the reprex package (v0.3.0.9000)
More evidence for the view that nest(iris) should warn. We warn in the parallel, inverse situation of unnest(df) being called with empty ....
library(tidyr)
packageVersion("tidyr")
#> [1] '0.8.99.9000'
df <- nest(iris, data = everything())
unnest(df)
#> Warning: `cols` is now required.
#> Please use `cols = c(data)`
#> # A tibble: 150 x 5
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <dbl> <dbl> <dbl> <dbl> <fct>
#> 1 5.1 3.5 1.4 0.2 setosa
#> 2 4.9 3 1.4 0.2 setosa
#> 3 4.7 3.2 1.3 0.2 setosa
#> 4 4.6 3.1 1.5 0.2 setosa
#> 5 5 3.6 1.4 0.2 setosa
#> 6 5.4 3.9 1.7 0.4 setosa
#> 7 4.6 3.4 1.4 0.3 setosa
#> 8 5 3.4 1.5 0.2 setosa
#> 9 4.4 2.9 1.4 0.2 setosa
#> 10 4.9 3.1 1.5 0.1 setosa
#> # … with 140 more rows
Created on 2019-08-13 by the reprex package (v0.3.0.9000)
This is also related to making ourselves cough up more precise words here: https://github.com/tidyverse/tidyr/commit/908da2c91fa1f169319b40640dad68e9c9e139b0#commitcomment-34644640
It's not really accurate to describe this as a reluctance to use ... for metadata. It's disliking the use of ... to absorb nothingness, which then implicitly takes on some other meaning ("everything" or "all list-columns" or what have you).
Facing the same issue here 😢.
Actually, it's happening in (at least known to me) one of the dependent packages https://github.com/nacnudus/unpivotr/issues/26
On CRAN version
require(tidyr)
#> Loading required package: tidyr
"Repository" %in% desc::desc(package = "tidyr")$fields()
#> [1] TRUE
desc::desc(package = "tidyr")$get_field("Repository")
#> [1] "CRAN"
packageVersion("tidyr")
#> [1] '0.8.3'
iris %>% nest(-Species, .key = "attr")
#> # A tibble: 3 x 2
#> Species attr
#> <fct> <list>
#> 1 setosa <tibble [50 x 4]>
#> 2 versicolor <tibble [50 x 4]>
#> 3 virginica <tibble [50 x 4]>
Created on 2019-08-19 by the reprex package (v0.3.0)
With dev-version
# after
# devtools::install_github("tidyverse/tidyr")
require(tidyr)
#> Loading required package: tidyr
# not in cran
# desc::desc(package = "tidyr")$get_field("Repository")
"Repository" %in% desc::desc(package = "tidyr")$fields()
#> [1] FALSE
packageVersion("tidyr")
#> [1] '0.8.99.9000'
iris %>% nest(-Species, .key = "attr")
#> Warning: All elements of `...` must be named.
#> Did you want `attr = c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width)`?
#> # A tibble: 3 x 2
#> Species attr
#> <fct> <list<df[,4]>>
#> 1 setosa [50 x 4]
#> 2 versicolor [50 x 4]
#> 3 virginica [50 x 4]
iris %>% nest(-Species, attr = c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width))
#> Warning: All elements of `...` must be named.
#> Did you want `data = c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width)`?
#> # A tibble: 3 x 2
#> Species data
#> <fct> <list<df[,4]>>
#> 1 setosa [50 x 4]
#> 2 versicolor [50 x 4]
#> 3 virginica [50 x 4]
# this is fine
iris %>% nest(attr = c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width))
#> # A tibble: 3 x 2
#> Species attr
#> <fct> <list<df[,4]>>
#> 1 setosa [50 x 4]
#> 2 versicolor [50 x 4]
#> 3 virginica [50 x 4]
Created on 2019-08-19 by the reprex package (v0.3.0)
@bedantaguru Your example is different and is a case that is already handled. Your example specifies that we will nest "everything but Species". This issue is about nest() calls that contain no specification at all.
To be clear, this warning is intended and the fact that unpivotr throws it means that unpivotr needs to adjust the way it calls nest() for dev tidyr. It's not currently flagged in our revdep check, though, so let me tag @nacnudus directly.
This turned out to be super simple 😬 so I probably shouldn't've put it for so long
Most helpful comment
@bedantaguru Your example is different and is a case that is already handled. Your example specifies that we will nest "everything but
Species". This issue is aboutnest()calls that contain no specification at all.To be clear, this warning is intended and the fact that unpivotr throws it means that unpivotr needs to adjust the way it calls
nest()for dev tidyr. It's not currently flagged in our revdep check, though, so let me tag @nacnudus directly.