Use of `focus` argument in `print()` produces an error
wurli opened this issue · comments
This is the case since {pillar} 1.8.0, which expects a pillar_focus
attribute rather than a focus
argument.
library(tibble)
df <- tibble(x = 1, y = 2)
print(df, focus = "x")
#> Error in tbl_format_setup(x, width = width, ..., n = n, max_extra_cols = max_extra_cols, : formal argument "focus" matched by multiple actual arguments
attr(df, "pillar_focus") <- "y"
print(df)
#> # A tibble: 1 x 2
#> # Focus columns: y
#> x y
#> <dbl> <dbl>
#> 1 1 2
Created on 2022-08-23 by the reprex package (v2.0.1)
Pillar issue #585 created for the same problem.
Thanks, good catch.
I'm not sure if we want to support a focus
argument to print()
. Can you please share a use case?
Previously I had been defining my own tbl
subclass which automatically focussed on certain columns when printing. Obviously the piller_focus
attribute is much nicer as I can now ditch my subclass and simply set the attribute. I just posted the issue as my code had suddenly stopped working and it took a few minutes of head-scratching to work out why.
Really, I think this isn't an issue with {tibble} but with {pillar}. The docs for tibble:::print.tbl_df()
point to pillar::tbl_format_setup()
for the dots argument, and this function still mentions the defunct focus
argument. Soft-deprecating focus
, improving the docs, improving the error message or any combination in {pillar} would hit the spot as far as I'm concerned :)
Thanks, let's handle this in pillar.
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.