vctrs
vctrs copied to clipboard
Obey max argument and max.print option in obj_print()?
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)
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