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

Better display for list columns if all elements have the same type #34

Closed
krlmlr opened this issue Aug 25, 2017 · 9 comments · Fixed by #153
Closed

Better display for list columns if all elements have the same type #34

krlmlr opened this issue Aug 25, 2017 · 9 comments · Fixed by #153
Labels
Projects
Milestone

Comments

@krlmlr
Copy link
Member

krlmlr commented Aug 25, 2017

e.g., nested data frames

From tidyverse/tibble#117.

@krlmlr krlmlr added this to To Do in krlmlr Sep 4, 2017
@hadley
Copy link
Member

hadley commented Sep 5, 2017

One idea: if every element has the same "type", display that in the header, and then display the dimension in each row.

@krlmlr
Copy link
Member Author

krlmlr commented Mar 1, 2018

We should also think about coloring list columns blue or green (#23 (comment)).

@wlandau
Copy link

wlandau commented Oct 13, 2018

For lists of symbols and language objects, it would be awesome to see the expr_text() of each element instead of <symbol> or <language>. One use case is drake::map_plan(), which accepts a data frame of function arguments.

library(tidyverse)
args <- expand.grid(
  data = c("simulated", "robinson_et_al", "smyth_et_al"),
  method = c("bayesian", "frequentist"),
  stringsAsFactors = FALSE
) %>%
  mutate(data = rlang::syms(data)) %>%
  as_tibble() %>%
  print()
#> # A tibble: 6 x 2
#>   data     method     
#>   <list>   <chr>      
#> 1 <symbol> bayesian   
#> 2 <symbol> bayesian   
#> 3 <symbol> bayesian   
#> 4 <symbol> frequentist
#> 5 <symbol> frequentist
#> 6 <symbol> frequentist

In map_plan(), characters get quotes and symbols do not. The distinction is extremely useful.

drake::map_plan(args, analyze)
#> # A tibble: 6 x 2
#>   target           command                                                
#>   <chr>            <chr>                                                  
#> 1 analyze_34dedc26 "analyze(data = simulated, method = \"bayesian\")"     
#> 2 analyze_bc3d5587 "analyze(data = robinson_et_al, method = \"bayesian\")"
#> 3 analyze_524f3aca "analyze(data = smyth_et_al, method = \"bayesian\")"   
#> 4 analyze_48fb9d8b "analyze(data = simulated, method = \"frequentist\")"  
#> 5 analyze_ee37695c "analyze(data = robinson_et_al, method = \"frequentist…
#> 6 analyze_70ba84cd "analyze(data = smyth_et_al, method = \"frequentist\")"

The command column of a drake plan can be a list of language objects rather than a character vector, and I may make language objects the default at some point. One minor source of friction is the printing.

plan %>%
  mutate(command = purrr::map(command, rlang::parse_expr)) %>%
  print()
#> # A tibble: 6 x 2
#>   target           command   
#>   <chr>            <list>    
#> 1 analyze_34dedc26 <language>
#> 2 analyze_bc3d5587 <language>
#> 3 analyze_524f3aca <language>
#> 4 analyze_48fb9d8b <language>
#> 5 analyze_ee37695c <language>
#> 6 analyze_70ba84cd <language>

I do realize that I can customize printing within a column, but I thought I would ask about the default first. I am not aware of a situation in which a column of <language> indicators is preferred.

@wlandau
Copy link

wlandau commented Feb 1, 2019

What are your current plans for this issue? I do not mean to rush anything, I am just asking because the priority and timing will affect how I solve it could improve the existing solution to ropensci/drake#700.

ropensci/drake#700 (comment) (using ropensci/drake@fa96707) is an example of what I am looking for. Without custom S3 magic, the command column would print as a <list> of <language>s.

@krlmlr
Copy link
Member Author

krlmlr commented May 3, 2019

We now have this in the PR:

pillar::pillar(vctrs::list_of(1:3))
#> <list<int>>
#>     1, 2, 3

Created on 2019-05-03 by the reprex package (v0.2.1)

@krlmlr
Copy link
Member Author

krlmlr commented May 3, 2019

And this with r-lib/vctrs#317:

pillar::pillar(vctrs::list_of(1:3, 4:100))
#> <list<int>>
#>         [3]
#>        [97]

Created on 2019-05-03 by the reprex package (v0.2.1)

@krlmlr krlmlr added this to the v1.4.0 milestone May 3, 2019
krlmlr automation moved this from Blocked to Done May 5, 2019
krlmlr added a commit that referenced this issue May 5, 2019
- `type_sum()` forwards to `vctrs::vec_ptype_abbr()` (#134). This makes sure that `list_of` columns (for values of the same type) are properly displayed (#34).
@wlandau
Copy link

wlandau commented May 6, 2019

I am still having trouble printing tibbles that contain lists of language objects. Should I open an issue in vctrs? Is this within scope?

utils::packageDescription("pillar")$RemoteSha
#> [1] "072fe73e660e8a891f1fbe08607eb60a190444f5"
utils::packageDescription("vctrs")$RemoteSha
#> [1] "25d8607960881c74d1d9272eb71580140311c00d"
tibble::tibble(x = list(quote(foo <- 0L)))
#> # A tibble: 1 x 1
#>   x         
#>   <list>    
#> 1 <language>
tibble::tibble(x = vctrs::list_of(quote(foo <- 0L)))
#> `list(...)[[1]]` must be a vector, not a call
vctrs::list_of(quote(foo <- 0L))
#> `list(...)[[1]]` must be a vector, not a call

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

@krlmlr
Copy link
Member Author

krlmlr commented May 6, 2019

Yes please -- we can't do anything here.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2020

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 Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
krlmlr
  
Done
3 participants