Shivvy
Shivvy

Reputation: 117

save_kable erasing Latex symbols in header

am attempting to save a kable html table with Latex symbols in the column names. This prints well in the Rmd, but when piped into save_kable() I lose the Latex formatting and get only raw text.

I am able to see this in my viewer window: enter image description here

But this is what get's saved:

enter image description here

I have tried installing ghostscript but it is not available in my version of R:

platform x86_64-apple-darwin17.0

arch x86_64 os darwin17.0 system x86_64, darwin17.0 status major 4 minor 0.3 year 2020 month 10 day 10 svn rev 79318 language R version.string R version 4.0.3 (2020-10-10) nickname Bunny-Wunnies Freak Out

Here is my data:


structure(list(`Log-Transformed Variable` = structure(c(1L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L), .Label = c("Saccade Frequency (Hz)", 
"Saccade Frequency > 0 (Hz)", "Avg Amplitude (°)", "Avg Horizontal Amplitude", 
"Avg Vertical Amplitude", "Avg Peak Velocity (°/s)", "Avg Horizontal Peak Velocity", 
"Avg Vertical Peak Velocity", "Avg Peak Acceleration (°/s²)", 
"Avg Horizontal Peak Acceleration", "Avg Vertical Peak Acceleration"
), class = "factor"), `$P$` = c(0.759, 0.539, 0.989, 0.144, 0.432, 
0.42, 0.435, 0.476, 0.209, 0.259), `$F$ Value` = c(0.095, 0.38, 
0, 2.169, 0.623, 0.656, 0.614, 0.512, 1.599, 1.291), `$\beta_1$` = c(-0.211, 
0.335, 0.009, 1.014, -0.461, -0.485, 0.568, 0.448, -1.022, 0.845
), `$\beta_0$` = c(49.005, 23.682, 32.211, 29.182, 30.303, 34.474, 
32.64, 34.973, 45.773, 36.487)), row.names = c(NA, -10L), class = "data.frame")

And my code:

df %>% kable(booktabs=T,row.names = F,escape = T,digits = 2)%>%
  kable_styling(latex_options = c("striped","hold_position"))%>%
  kable_classic(full_width = T, html_font = font)%>%
  add_indent(c(3,4,6,7,9,10),level_of_indent=1)%>%
  footnote(symbol=c("Significant at p<0.05","Significant at p<0.01"))%>%
  save_kable(file="Output Figures/Tables/LearningModel.png",zoom=2)
  

Upvotes: 4

Views: 150

Answers (0)

Related Questions