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

"{" character breaks the printing of listings #225

Closed
BFalquet opened this issue Sep 10, 2024 · 3 comments · Fixed by #235
Closed

"{" character breaks the printing of listings #225

BFalquet opened this issue Sep 10, 2024 · 3 comments · Fixed by #235
Assignees
Labels
bug Something isn't working sme

Comments

@BFalquet
Copy link

BFalquet commented Sep 10, 2024

{ character makes the printing of listings bug (creation is ok)

library(rlistings)
#> Loading required package: formatters
#> 
#> Attaching package: 'formatters'
#> The following object is masked from 'package:base':
#> 
#>     %||%
#> Loading required package: tibble
dat <- ex_adae
dat$AENDY[3:6] <- "something {haha} something"
lsting <- as_listing(dat[1:25, ],
  key_cols = c("USUBJID", "AESOC"),
  disp_cols = c("STUDYID", "SEX", "ASEQ", "RANDDT", "ASTDY", "AENDY"),
  default_formatting = list(
    all = fmt_config(align = "left"),
    numeric = fmt_config(
      format = "xx.xx",
      na_str = "<No data>",
      align = "right"
    )
  )
)

lsting
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'toString': values must be length 1,
#>  but FUN(X[[1]]) result is length 0

But this works

dat$AENDY[3:6] <- "something (haha) something"
lsting <- as_listing(dat[1:25, ],
  key_cols = c("USUBJID", "AESOC"),
  disp_cols = c("STUDYID", "SEX", "ASEQ", "RANDDT", "ASTDY", "AENDY"),
  default_formatting = list(
    all = fmt_config(align = "left"),
    numeric = fmt_config(
      format = "xx.xx",
      na_str = "<No data>",
      align = "right"
    )
  )
)

lsting
#> Unique Subject Identifier   Primary System Organ Class   Study Identifier   Sex   Analysis Sequence Number   Date of Randomization   Analysis Start Relative Day   Analysis End Relative Day 
#> —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#> AB12345-BRA-1-id-134        cl A                         AB12345            M                         3.00   2021-06-09                                   497.00   something (haha) something
#>                                                          AB12345            M                         4.00   2021-06-09                                   608.00   something (haha) something
#>                             cl B                         AB12345            M                         1.00   2021-06-09                                   251.00   518                       
#>                             cl D                         AB12345            M                         2.00   2021-06-09                                   304.00   559                       
#> AB12345-BRA-1-id-141        cl A                         AB12345            F                         3.00   2021-02-25                                   493.00   516                       
#>                                                          AB12345            F                         4.00   2021-02-25                                   600.00   693                       
#>                                                          AB12345            F                         5.00   2021-02-25                                   635.00   678                       
#>                             cl B                         AB12345            F                         1.00   2021-02-25                                   259.00   something (haha) something
#>                             cl D                         AB12345            F                         2.00   2021-02-25                                   303.00   something (haha) something
#>                                                          AB12345            F                         6.00   2021-02-25                                   730.00   731                       
#> AB12345-BRA-1-id-236        cl B                         AB12345            M                         1.00   2021-08-17                                    22.00   432                       
#>                                                          AB12345            M                         2.00   2021-08-17                                   181.00   698                       
#>                                                          AB12345            M                         3.00   2021-08-17                                   702.00   706                       
#> AB12345-BRA-1-id-265        cl C                         AB12345            M                         1.00   2020-05-09                                    48.00   92                        
#>                                                          AB12345            M                         4.00   2020-05-09                                   403.00   440                       
#>                             cl D                         AB12345            M                         2.00   2020-05-09                                   200.00   362                       
#>                                                          AB12345            M                         3.00   2020-05-09                                   392.00   413                       
#> AB12345-BRA-1-id-42         cl A                         AB12345            M                         4.00   2020-08-06                                   160.00   419                       
#>                                                          AB12345            M                         6.00   2020-08-06                                   460.00   654                       
#>                                                          AB12345            M                         8.00   2020-08-06                                   476.00   588                       
#>                             cl B                         AB12345            M                         5.00   2020-08-06                                   292.00   342                       
#>                                                          AB12345            M                         7.00   2020-08-06                                   470.00   600                       
#>                             cl C                         AB12345            M                         1.00   2020-08-06                                    39.00   545                       
#>                                                          AB12345            M                         3.00   2020-08-06                                    95.00   401                       
#>                             cl D                         AB12345            M                         2.00   2020-08-06                                    65.00   694

Created on 2024-09-10 with reprex v2.1.1

@BFalquet BFalquet added the bug Something isn't working label Sep 10, 2024
@shajoezhu
Copy link
Collaborator

it's the "{" throwing things off

@Melkiades
Copy link
Contributor

We need to add the proper error messaging:

library(rtables)
#> Loading required package: formatters
#> Loading required package: magrittr
#> 
#> Attaching package: 'rtables'
#> The following object is masked from 'package:utils':
#> 
#>     str
dat <- ex_adae
dat$AENDY[3:6] <- "something \\{haha\\} something"
basic_table() %>% 
  split_rows_by("AENDY") %>% 
  analyze("SEX") %>% 
  build_table(head(dat))
#> Error in check_ok_label(label): Labels cannot contain { or } due to their use for indicating referential footnotes

Created on 2024-09-10 with reprex v2.1.0

@BFalquet
Copy link
Author

+1, just an assertion would be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sme
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants