pillar icon indicating copy to clipboard operation
pillar copied to clipboard

df-cols are hidden before any other columns, which feels wrong

Open DavisVaughan opened this issue 3 months ago • 2 comments

Consider the following df with a df-col up front

col <- tibble::tibble(foo = 1, bar = 2, baz = 3)
df <- tibble::tibble(col = col, x = 1, y = 2, z = 3, a = 4, b = 5, c = 6)

It's pretty confusing to me that, in a narrow console, baz is dropped first. I would have expected the final c column to be dropped first

Image

It gets particularly hard to explain when you make it even more narrow, where c is dropped and some, but not all, of the df-col columns are hidden.

Image

I have a feeling the current rule is something like:

Hide all but the first df-col columns first, then starting hiding non-df-col columns from last to first until it fits

But I think a simpler rule overall would just be:

Hide columns from last to first until it fits

So in this case you'd just hide c, then b, then a, etc, until it fits.

DavisVaughan avatar Oct 09 '25 14:10 DavisVaughan

Thanks. The display shows as many columns as possible. More columns of a packed column are considered a "detail" that will be truncated first (similarly to an overly long character column), in favor of showing more columns. Does this explain the behavior?

In the proposed behavior, a deeply packed column would be expanded, hiding all other columns. Is this what we want?

I don't have a strong opinion; both options have advantages and could coexist in the same codebase, IIRC.

krlmlr avatar Oct 09 '25 17:10 krlmlr

More columns of a packed column are considered a "detail" that will be truncated first (similarly to an overly long character column), in favor of showing more columns

Yea that does explain the behavior and is what I guessed was happening, I think I just find it unintuitive. Packed or not, I think I want to read the column names from left to right and only have columns at the far right be ones that get dropped off.


I guess I see truncation of the character column here as being fine

library(tibble)

tibble(
  a = 1,
  b = paste0(rep("x", 1000), collapse = ""),
  c = 1
)
#> # A tibble: 1 × 3
#>       a b                                                                      c
#>   <dbl> <chr>                                                              <dbl>
#> 1     1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx…     1

Because I still see all the column names a, b, c and only the "data" inside column b is truncated.

This just feels worse to me

col <- tibble::tibble(foo = 1, bar = 2)
df <- tibble::tibble(col = col, x = 1, y = 2, z = 3, a = 4, b = 5, c = 6)
df
Image

I see how you could argue that col$bar is "data" inside column col as well, but I think the fact that we write out # ℹ 2 more variables: col$bar <dbl>, c <dbl> is proof that we are treating col$bar more like a column than as "data" within a column, so the normal column truncation rules of "drop the right columns first" should apply.

DavisVaughan avatar Oct 09 '25 17:10 DavisVaughan