8  Sanitize

A brief word about sanitizing table contents.

8.1 Notes

x <- ptdata() %>% 
  st_new(notes = "EDA_summary = TRUE") %>% 
  st_make(inspect = TRUE) %>% 
  get_stable_data() 

x$notes
[1] "EDA\\_summary = TRUE"

8.2 File names

x <- ptdata() %>% st_new() %>% 
  st_files(r = "my_script.R") %>% 
  st_make(inspect = TRUE) %>% 
  get_stable_data() 

x$notes
[1] "Source code: my\\_script.R"

8.3 Column names

out <- 
  tibble(a_1 = 5) %>% 
  stable(inspect = TRUE) %>% 
  get_stable_data()

out$cols_tex
[1] "a\\_1 \\\\"

8.4 Main table contents

out <- 
  tibble(a = "5_2") %>% 
  stable(inspect = TRUE) %>% 
  get_stable_data()

out$tab
[1] "5\\_2 \\\\"

8.5 Span titles

out <- 
  ptdata() %>% 
  stable(
    inspect = TRUE, 
    span = colgroup("foo_this", WT:SCR)
  ) %>% get_stable_data()

out$span_data$tex
[1] "\\multicolumn{4}{c}{} & \\multicolumn{5}{c}{foo\\_this} \\\\"
[2] "\\cmidrule(lr){5-9}"                                         

8.6 Panel names

data <- tibble(
  a = c("a_1", "a_1", "a_1", "a_2", "a_2"), 
  b = letters[1:5]
)

out <- stable(data, panel = "a") 
out[grepl("multicolumn", out)]
[1] "\\multicolumn{1}{l}{\\textbf{a\\_1}}\\\\%--pmtables-insert-panel"        
[2] "\\hline \\multicolumn{1}{l}{\\textbf{a\\_2}}\\\\%--pmtables-insert-panel"

8.7 cols_extra input

x <- letters[1:5]
data <- tibble(a = x, b = x, c = x)
xtra <- tibble(a = "foo%", b = "$\\mu$g", c = "1234 \\% %")
out <- stable(data, cols_extra = xtra)
out[grepl("%", out, fixed = TRUE)]
[1] "foo\\% & $\\mu$g & 1234 \\% % \\\\"