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

Obey max argument and max.print option in obj_print()? #1355

Open
krlmlr opened this issue Apr 8, 2021 · 1 comment · May be fixed by #1482
Open

Obey max argument and max.print option in obj_print()? #1355

krlmlr opened this issue Apr 8, 2021 · 1 comment · May be fixed by #1482
Labels
feature a feature request or enhancement

Comments

@krlmlr
Copy link
Member

krlmlr commented Apr 8, 2021

We're already obeying getOption("max.print") via print(format(x)), but we're still calling format() on the full vctr. We could do a better job by providing the necessary infrastructure in obj_print() and passing max to obj_print_footer() .

I'll experiment with pillar::num() and pillar::char() .

print(vctrs::new_vctr(letters), max = 10)
#> <vctrs_vctr[26]>
#>  [1] a b c d e f g h i j k l m n o p q r s t u v w x y z
options(max.print = 5)
print(vctrs::new_vctr(letters))
#> <vctrs_vctr[26]>
#> [1] a b c d e
#>  [ reached getOption("max.print") -- omitted 21 entries ]

print(letters, max = 10)
#>  [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
#>  [ reached getOption("max.print") -- omitted 16 entries ]
print(letters)
#> [1] "a" "b" "c" "d" "e"
#>  [ reached getOption("max.print") -- omitted 21 entries ]

Created on 2021-04-08 by the reprex package (v1.0.0)

@DavisVaughan
Copy link
Member

I do this in clock too, since formatting the whole date-time / calendar object can be slow https://github.com/r-lib/clock/blob/3f3636a876718fa1e9ad5357f404152bdc57c443/R/calendar.R#L3-L29

@lionel- lionel- added the feature a feature request or enhancement label Oct 25, 2021
@krlmlr krlmlr linked a pull request Oct 27, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants