pillar icon indicating copy to clipboard operation
pillar copied to clipboard

Use of `focus` argument causes an error

Open wurli opened this issue 1 year ago • 2 comments

This is because format_tbl() no longer includes a focus argument, but rather an input with a pillar_focus attribute. This can result in upstream issues in tibble() - see tibble issue #1351 for details.

I'd suggest either retaining a soft-deprecated focus argument and using something like the following in format_tbl(), or improving the error messages somehow (although the focus argument was experimental to begin with).

  #... From line 66
  setup <- tbl_format_setup(x,
    width = width, ...,
    n = n,
    max_extra_cols = max_extra_cols,
    max_footer_lines = max_footer_lines,
    
    # `%||%` allows a user to override the attribute value, meaning old code won't break
    focus = focus %||% attr(x, "pillar_focus")
  )

wurli avatar Aug 23 '22 09:08 wurli

Reprex using only pillar:

tbl <- pillar:::new_tbl(list(a = 1))
print(tbl, focus = "a")
#> Error in tbl_format_setup(x, width = width, ..., n = n, max_extra_cols = max_extra_cols, : formal argument "focus" matched by multiple actual arguments

Created on 2022-08-28 by the reprex package (v2.0.1)

krlmlr avatar Aug 28 '22 02:08 krlmlr

  • [ ] Change ?tibble::formatting, the ellipsis is never passed
  • [ ] Change documentation here

Needs https://github.com/r-lib/rlang/issues/1517 to fully clean up the docs and behavior.

krlmlr avatar Oct 30 '22 19:10 krlmlr