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

row width is too large with multiple date time columns #366

Closed
jmbarbone opened this issue Aug 10, 2021 · 3 comments · Fixed by #372
Closed

row width is too large with multiple date time columns #366

jmbarbone opened this issue Aug 10, 2021 · 3 comments · Fixed by #372
Labels
Milestone

Comments

@jmbarbone
Copy link

I'm seeing that when printing a tibble with multiple dttm columns the row width is too large and overflowing onto the next lines.

This example sets the width option and returns the length of the rows. This occurs on multiple rows, but only using one here for simplicity.

ls <- rep(list(a = as.POSIXct("2021-08-10 12:03:56")), 8)
names(ls) <- seq_along(ls)
res <- tibble::as_tibble(c(list(a = "A character vector"), ls))

row_length_with_width <- function(w) {
  withr::with_options(
    list(width = w, crayon.enabled = FALSE), 
    nchar(capture.output(res)[4])
  )
}

s <- seq(80, 180, 10)
names(s) <- s
sapply(s, row_length_with_width)
#>  80  90 100 110 120 130 140 150 160 170 180 
#>  80 100 100 120 120 140 140 160 160 180 180

Created on 2021-08-10 by the reprex package (v2.0.0)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.1.0 (2021-05-18)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/New_York            
#>  date     2021-08-10                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version    date       lib source                       
#>  backports     1.2.1      2020-12-09 [1] CRAN (R 4.1.0)               
#>  cli           3.0.1      2021-07-17 [1] CRAN (R 4.1.0)               
#>  crayon        1.4.1      2021-02-08 [1] CRAN (R 4.1.0)               
#>  digest        0.6.27     2020-10-24 [1] CRAN (R 4.1.0)               
#>  ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.1.0)               
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.1.0)               
#>  fansi         0.5.0      2021-05-25 [1] CRAN (R 4.1.0)               
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.1.0)               
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.1.0)               
#>  highr         0.9        2021-04-16 [1] CRAN (R 4.1.0)               
#>  htmltools     0.5.1.1    2021-01-22 [1] CRAN (R 4.1.0)               
#>  knitr         1.33       2021-04-24 [1] CRAN (R 4.1.0)               
#>  lifecycle     1.0.0      2021-02-15 [1] CRAN (R 4.1.0)               
#>  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.1.0)               
#>  pillar        1.6.2.9000 2021-08-10 [1] Github (r-lib/pillar@9f20762)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.1.0)               
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.1.0)               
#>  reprex        2.0.0      2021-04-02 [1] CRAN (R 4.1.0)               
#>  rlang         0.4.11     2021-04-30 [1] CRAN (R 4.1.0)               
#>  rmarkdown     2.9        2021-06-15 [1] CRAN (R 4.1.0)               
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.1.0)               
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.1.0)               
#>  stringi       1.7.3      2021-07-16 [1] CRAN (R 4.1.0)               
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.1.0)               
#>  styler        1.5.1      2021-07-13 [1] CRAN (R 4.1.0)               
#>  tibble        3.1.3      2021-07-23 [1] CRAN (R 4.1.0)               
#>  utf8          1.2.2      2021-07-24 [1] CRAN (R 4.1.0)               
#>  vctrs         0.3.8      2021-04-29 [1] CRAN (R 4.1.0)               
#>  withr         2.4.2      2021-04-18 [1] CRAN (R 4.1.0)               
#>  xfun          0.24       2021-06-15 [1] CRAN (R 4.1.0)               
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.1.0)               
#> 
#> [1] C:/Users/jbarbone/Documents/R/win-library/4.1
#> [2] C:/Program Files/R/R-4.1.0/library

image

@krlmlr
Copy link
Member

krlmlr commented Oct 4, 2021

Thanks, confirmed -- also for POSIXt columns:

getOption("width")
#> [1] 80
tibble::tibble(a = paste(rep("x", 60), collapse = ""), b = Sys.time())
#> # A tibble: 1 × 2
#>   a                                                            b                  
#>   <chr>                                                        <dttm>             
#> 1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2021-10-04 04:57:40
tibble::tibble(a = paste(rep("x", 70), collapse = ""), b = Sys.time())
#> # A tibble: 1 × 2
#>   a                                                                      b                  
#>   <chr>                                                                  <dttm>             
#> 1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2021-10-04 04:57:40
tibble::tibble(a = paste(rep("x", 80), collapse = ""), b = Sys.time())
#> # A tibble: 1 × 2
#>   a                                                          b                  
#>   <chr>                                                      <dttm>             
#> 1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx… 2021-10-04 04:57:40

Created on 2021-10-04 by the reprex package (v2.0.1)

@krlmlr krlmlr added the bug label Oct 4, 2021
@krlmlr krlmlr added this to the 1.6.4 milestone Oct 17, 2021
krlmlr added a commit that referenced this issue Oct 17, 2021
- Fix printing for some tibbles where a fixed-width column is followed by a column with variable width (#366).
@krlmlr
Copy link
Member

krlmlr commented Oct 17, 2021

Thanks again for the great description and example!

krlmlr added a commit that referenced this issue Oct 18, 2021
pillar 1.6.4

- Fix printing for some tibbles where a fixed-width column is followed by a column with variable width (#366).
- Avoid nested backtick blocks in vignette.

- `colonnade()` no longer exists, `squeeze()` and `extra_cols()` now raise an error (#272).
- `num()` requires an integerish `digits` argument (#362).

- Link to tibble vignettes and documentation pages.
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants