Skip to content

Prettyprint.char does not count newlines #6738

@DavZim

Description

@DavZim

This is most likely a minor issue as it only affects prints.

Setting data.table.prettyprint.char to some value will not result in a character vector of that length as it ignores newline characters.
I've found that it ignores \n, but also \t.

MWE

options(datatable.prettyprint.char = 3)

data.table::data.table(x = c("1234", "12\n\n\n\n\n34", "12\t\t\t\t\t\t34"))
#>                     x
#>                <char>
#> 1:             123...
#> 2:   12\n\n\n\n\n3...
#> 3: 12\t\t\t\t\t\t3...

I would expect to see

data.table::data.table(x = c("1234", "12\n\n\n\n\n34", "12\t\t\t\t\t\t34"))
#>           x
#>      <char>
#> 1:   123...
#> 2:  12\n...
#> 3:  12\t...

Session info

Note I have also tested and reproduced the bug with version 1.16.99 (at the time of writing this corresponds to 3a7ec2d)

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.0 (2024-04-24)
#>  os       Ubuntu 22.04.4 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Etc/UTC
#>  date     2025-01-20
#>  pandoc   3.1.1 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.6.3   2024-06-21 [1] RSPM (R 4.4.0)
#>  data.table    1.16.4  2024-12-06 [1] RSPM (R 4.4.0)
#>  rstudioapi    0.16.0  2024-03-24 [1] RSPM (R 4.4.0)
#>  sessioninfo   1.2.2   2021-12-06 [1] RSPM (R 4.4.0)
#> 
#>  [1] /home/dazimme/R/x86_64-pc-linux-gnu-library/4.4
#>  [2] /opt/R/4.4.0/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions