Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy dots in bind_rows(), bind_cols() and combine() #3407

Closed
krlmlr opened this issue Mar 12, 2018 · 5 comments
Closed

Tidy dots in bind_rows(), bind_cols() and combine() #3407

krlmlr opened this issue Mar 12, 2018 · 5 comments
Labels

Comments

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Mar 12, 2018

to resolve ambiguity when these functions are used with just one argument, see #3387 (comment):

library(tidyverse)
combine(list(1))
#> [1] 1
combine(list(1), list(2))
#> [[1]]
#> [1] 1
#> 
#> [[2]]
#> [1] 2

Created on 2018-03-12 by the reprex package (v0.2.0).

The first call should also return a list, if unpacking is desired, the user can use combine(!!!list(1)) (which currently doesn't work).

Implement new verbs, or support a compatibility argument via pkgconfig.

@hadley
Copy link
Member

@hadley hadley commented Apr 5, 2018

I don't think this is tidy evaluation so much as tidy dots.

@krlmlr krlmlr changed the title Tidy evaluation in bind_rows(), bind_cols() and combine() Tidy dots in bind_rows(), bind_cols() and combine() Apr 6, 2018
@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented May 29, 2018

bind_rows handles tidy dots already:

library(tidyverse)

datas <- map( 1:3, ~tibble(x = seq_len(.)))
bind_rows(!!!datas)
#> # A tibble: 6 x 1
#>       x
#>   <int>
#> 1     1
#> 2     1
#> 3     2
#> 4     1
#> 5     2
#> 6     3
bind_rows(!!!datas, tibble(x = 5))
#> # A tibble: 7 x 1
#>       x
#>   <dbl>
#> 1     1
#> 2     1
#> 3     2
#> 4     1
#> 5     2
#> 6     3
#> 7     5

So does bind_cols:

library(tidyverse)

datas <- map( c("a", "b", "c"), ~tibble( !!. := 1:10))
bind_cols(!!!datas)
#> # A tibble: 10 x 3
#>        a     b     c
#>    <int> <int> <int>
#>  1     1     1     1
#>  2     2     2     2
#>  3     3     3     3
#>  4     4     4     4
#>  5     5     5     5
#>  6     6     6     6
#>  7     7     7     7
#>  8     8     8     8
#>  9     9     9     9
#> 10    10    10    10
bind_cols(!!!datas, tibble(d = 1:10))
#> # A tibble: 10 x 4
#>        a     b     c     d
#>    <int> <int> <int> <int>
#>  1     1     1     1     1
#>  2     2     2     2     2
#>  3     3     3     3     3
#>  4     4     4     4     4
#>  5     5     5     5     5
#>  6     6     6     6     6
#>  7     7     7     7     7
#>  8     8     8     8     8
#>  9     9     9     9     9
#> 10    10    10    10    10

@hadley
Copy link
Member

@hadley hadley commented May 29, 2018

So this is more about disabling existing behaviour than adding new behaviour?

@krlmlr
Copy link
Member Author

@krlmlr krlmlr commented May 30, 2018

Yes, the first expression in the reprex should return a list. I commented in the PR.

krlmlr added a commit that referenced this issue Sep 17, 2018
krlmlr added a commit that referenced this issue Sep 22, 2018
krlmlr added a commit that referenced this issue Dec 14, 2018
romainfrancois added a commit that referenced this issue Dec 14, 2018
@lock
Copy link

@lock lock bot commented Jun 12, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jun 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants