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

Should tibble::tibble() use quos(..., .named = TRUE)? #613

Closed
DavisVaughan opened this issue Jun 24, 2019 · 9 comments
Closed

Should tibble::tibble() use quos(..., .named = TRUE)? #613

DavisVaughan opened this issue Jun 24, 2019 · 9 comments
Labels
vctrs ↗️ Requires vctrs package
Milestone

Comments

@DavisVaughan
Copy link
Member

Is automatically adding names to unnamed ... too surprising? Was this first error expected?

# surprising?
tibble::tibble(!!! list(mtcars[,1:2], mtcars[,3:4]))
#> Column name `<data.frame>` must not be duplicated.
#> Use .name_repair to specify repair.

# a result of:
rlang::quos(!!! list(mtcars[,1:2], mtcars[,3:4]), .named = TRUE)
#> <list_of<quosure>>
#> 
#> $`<data.frame>`
#> <quosure>
#> expr: ^<data.frame>
#> env:  empty
#> 
#> $`<data.frame>`
#> <quosure>
#> expr: ^<data.frame>
#> env:  empty

# can be "fixed" with
tibble::tibble(!!! list(x = mtcars[,1:2], y = mtcars[,3:4]))
#> # A tibble: 32 x 2
#>    x$mpg  $cyl y$disp   $hp
#>    <dbl> <dbl>  <dbl> <dbl>
#>  1  21       6   160    110
#>  2  21       6   160    110
#>  3  22.8     4   108     93
#>  4  21.4     6   258    110
#>  5  18.7     8   360    175
#>  6  18.1     6   225    105
#>  7  14.3     8   360    245
#>  8  24.4     4   147.    62
#>  9  22.8     4   141.    95
#> 10  19.2     6   168.   123
#> # … with 22 more rows

tibble::tibble(!!! list(mtcars[,1:2], mtcars[,3:4]), .name_repair = "minimal")
#> # A tibble: 32 x 2
#>    `<data.frame>`$mpg  $cyl `<data.frame>`$disp   $hp
#>                 <dbl> <dbl>               <dbl> <dbl>
#>  1               21       6                160    110
#>  2               21       6                160    110
#>  3               22.8     4                108     93
#>  4               21.4     6                258    110
#>  5               18.7     8                360    175
#>  6               18.1     6                225    105
#>  7               14.3     8                360    245
#>  8               24.4     4                147.    62
#>  9               22.8     4                141.    95
#> 10               19.2     6                168.   123
#> # … with 22 more rows

Created on 2019-06-24 by the reprex package (v0.2.1)

@krlmlr
Copy link
Member

krlmlr commented Jun 24, 2019

Related: #581 (which is about auto-splicing).

@krlmlr
Copy link
Member

krlmlr commented Jun 29, 2019

Maybe we should append ...# suffixes to auto-named columns here?

@lionel-: Should this be the default, or perhaps an option?

@lionel-
Copy link
Member

lionel- commented Jul 1, 2019

The plan was originally to have name repair in rlang but it is now in vctrs instead. Can you use .named = FALSE and name the inputs manually?

@krlmlr krlmlr added the vctrs ↗️ Requires vctrs package label Aug 7, 2019
@krlmlr
Copy link
Member

krlmlr commented Oct 23, 2019

Ideally I'd like to maintain full-width expressions, but width and printer in exprs_auto_name() are deprecated. Are there better alternatives?

@lionel-
Copy link
Member

lionel- commented Oct 24, 2019

You can auto-name yourself in this case. I don't think full-width expressions are ideal though.

@krlmlr
Copy link
Member

krlmlr commented Oct 24, 2019

I don't think I want to auto-name myself, because we're striving for consistency with mutate() and summarize(). The auto-naming should live somewhere central -- I don't mind implementing it, but then dplyr might want to follow the same strategy. Or we do whatever rlang does, or perhaps tweak rlang?

@lionel-
Copy link
Member

lionel- commented Oct 24, 2019

dplyr just uses .named = TRUE.

@krlmlr
Copy link
Member

krlmlr commented Oct 25, 2019

With current tibble:

tibble::tibble(!!! list(mtcars[,1:2], mtcars[,3:4]))
#> # A tibble: 32 x 4
#>      mpg   cyl  disp    hp
#>    <dbl> <dbl> <dbl> <dbl>
#>  1  21       6  160    110
#>  2  21       6  160    110
#>  3  22.8     4  108     93
#>  4  21.4     6  258    110
#>  5  18.7     8  360    175
#>  6  18.1     6  225    105
#>  7  14.3     8  360    245
#>  8  24.4     4  147.    62
#>  9  22.8     4  141.    95
#> 10  19.2     6  168.   123
#> # … with 22 more rows

Created on 2019-10-25 by the reprex package (v0.3.0)

@krlmlr krlmlr closed this as completed Oct 25, 2019
@krlmlr krlmlr added this to the 3.0.0 milestone Mar 21, 2020
@github-actions
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
vctrs ↗️ Requires vctrs package
Projects
None yet
Development

No branches or pull requests

3 participants