insightsengineering / formatters

A framework for creating listings of raw data that include specialized formatting, headers, footers, referential footnotes, and pagination.
https://insightsengineering.github.io/formatters/
Other
15 stars 6 forks source link

Fixing \n in row and column labels (i.e. allowing it) #208

Closed Melkiades closed 1 year ago

Melkiades commented 1 year ago

tlg-catalog/stable/tables/pharmacokinetic/pkct01

Summary Concentration Table

https://insightsengineering.github.io/tlg-catalog/stable/tables/pharmacokinetic/pkct01.html

Originally posted by @giscus in https://github.com/insightsengineering/tlg-catalog/discussions/48

Places to work on

library(rtables)
library(dplyr)
DM_trick <- DM %>% 
  mutate(ARM2 = sample(c("TWO\nwords\n", "A word"), replace = TRUE, nrow(DM))) # last \n is eaten up
levels(DM_trick$SEX)[3] <- "U\nN\nD\n"
tbl <- basic_table() %>% 
  split_rows_by("SEX", split_label = "m\sdssda\nsda\n", label_pos = "visible") %>% # last \n bug
  split_cols_by("ARM2", split_label = "sda") %>% 
  analyze("BMRKR1", na_str = "asd\nasd") %>%  # \n error
  build_table(DM_trick)

top_left(tbl) <- c("a", "b\nd", "c\n\n") # last \n is eaten up, if in the middle error
main_title(tbl) <- "why not \nalso here\n"
matrix_form(tbl)