haleyjeppson / ggmosaic

Mosaicplots in the ggplot2 framework
https://haleyjeppson.github.io/ggmosaic/
167 stars 21 forks source link

Failure to Knit to PDF Document #63

Open ccb60 opened 1 year ago

ccb60 commented 1 year ago

Even a very simple RMarkdown document that knits to PDF fails to compile to a PDF. If I run a *.Rmd file with just the following contents:

---
title: "Test Mosaic Plot"
date: "2023-01-18"
output:
  pdf_document
---
library(ggmosaic)
ggplot(data = fly) +
  geom_mosaic(aes(x = product(rude_to_recline), fill=do_you_recline)) +
  theme_mosaic()

It generates the following error message:

! LaTeX Error: Unicode character ^^[ (U+001B)
               not set up for use with LaTeX.

Error: LaTeX failed to compile Initial-Data-Review-TEST.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See Initial-Data-Review-TEST.log for more info.
Execution halted

No Problem with ggplot2 graphics

I know that knitting, LaTeX rendering, and PDF output are all prone to hidden conflicts, but I have no trouble generating PDF output of other ggplot2 graphics.

The Set Up

RStudio 2022.12.0+353 "Elsbeth Geranium" Release (7d165dcfc1b6d300eb247738db2c7076234f6ef0, 2022-12-03) for Windows Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2022.12.0+353 Chrome/102.0.5005.167 Electron/19.1.3 Safari/537.36

R version 4.2.2 (2022-10-31 ucrt) -- "Innocent and Trusting"

knitr version 1.41 markdown Vesion 1.4 tinytex version 0.43

ccb60 commented 1 year ago

Further investigation shows the behavior is also triggered by saving the plot using ggsave(). The plot is saved, but the PDF fails to knit, with the same message. But showing the saved graphic does not cause a problem.

Similar behavior (failure to knit if the Rmarkdown document shows or saves a mosaic plot) occurs when knitting to a Word document, but not when knitting to an HTML document or github_document.