rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.86k stars 969 forks source link

Suddenly cannot set device as svg and use thematic at the same time. #2156

Closed py9mrg closed 3 years ago

py9mrg commented 3 years ago

Hello,

I have a dashboard for which I have been using the svg device for plots and thematic for automatic theming of the plots. It has worked fine but between the last generation of the dashboard (11th May) and now, something has broken. I've tried rolling back package versions of flexdashboard, knitr, rmarkdown, thematic, bslib, ggplot2, but I can't seem to find the culprit. Initially I posted an issue on the flexdashboard GH, but noticed that the same occurs if I change output to html_document, so presumably it's a more fundamental issue and this is a better place to post.

Here's an MWE illustrating the problem:

---
title: "Untitled" 
output: 
  html_document:
    theme:
      bootswatch: cosmo
      base_font:
        google: Open Sans
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, dev = "svg")
library(flexdashboard)
library(ggplot2)
thematic::thematic_rmd(font = "auto")

Chart A

ggplot(iris, (aes(Sepal.Width, Sepal.Length))) +
  geom_point()

This will cause knitr compilation to hang at the first chunk that creates a plot (the only chunk, in this case). But if you comment out either the knitr line (or change it to png) **or** the thematic_rmd call, then it will compile perfectly fine. 

The **really** weird thing is that loading the thematic package will cause the same problem, even if you don't use any thematic functions - the following won't compile unless either the thematic library is not loaded or the device is not set to svg:

````r
---
title: "Untitled" 
output: 
  html_document:
    theme:
      bootswatch: cosmo
      base_font:
        google: Open Sans
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, dev = "svg")
library(flexdashboard)
library(ggplot2)
library(thematic)

Chart A

ggplot(iris, (aes(Sepal.Width, Sepal.Length))) +
  geom_point()

```r
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043), RStudio 1.4.1717

Locale:
  LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
  LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

Package version:
  base64enc_0.1.3   digest_0.6.27     evaluate_0.14     glue_1.4.2        graphics_4.1.0    grDevices_4.1.0   highr_0.9         htmltools_0.5.1.1
  jsonlite_1.7.2    knitr_1.33        magrittr_2.0.1    markdown_1.1      methods_4.1.0     mime_0.10         rlang_0.4.11      rmarkdown_2.8.6  
  stats_4.1.0       stringi_1.6.2     stringr_1.4.0     tinytex_0.32      tools_4.1.0       utils_4.1.0       xfun_0.23         yaml_2.2.1       

Pandoc version: 2.14.0.1

Checklist

When filing a bug report, please check the boxes below to confirm that you have provided us with the information we need. Have you:

cderv commented 3 years ago

Thanks for the report.

This will cause knitr compilation to hang at the first chunk that creates a plot (the only chunk, in this case). But if you comment out either the knitr line (or change it to png) or the thematic_rmd call, then it will compile perfectly fine.

This first example is working for me - I can't reproduce.

the following won't compile unless either the thematic library is not loaded or the device is not set to svg:

This is also working for me - I can't reproduce either

Packages info ```r ! package * version date lib source base64enc 0.1-3 2015-07-28 [1] standard (@0.1-3) cli 2.5.0 2021-04-26 [1] standard (@2.5.0) colorspace 2.0-1 2021-05-04 [1] standard (@2.0-1) crayon 1.4.1 2021-02-08 [1] standard (@1.4.1) digest 0.6.27 2020-10-24 [1] standard (@0.6.27) ellipsis 0.3.2 2021-04-29 [1] standard (@0.3.2) evaluate 0.14 2019-05-28 [1] standard (@0.14) fansi 0.5.0 2021-05-25 [1] standard (@0.5.0) farver 2.1.0 2021-02-28 [1] standard (@2.1.0) ggplot2 3.3.3 2020-12-30 [1] standard (@3.3.3) glue 1.4.2 2020-08-27 [1] standard (@1.4.2) gtable 0.3.0 2019-03-25 [1] standard (@0.3.0) highr 0.9 2021-04-16 [1] standard (@0.9) htmltools 0.5.1.1 2021-01-22 [1] standard (@0.5.1.1) isoband 0.2.4 2021-03-03 [1] standard (@0.2.4) jsonlite 1.7.2 2020-12-09 [1] standard (@1.7.2) knitr 1.33 2021-04-24 [1] standard (@1.33) labeling 0.4.2 2020-10-20 [1] standard (@0.4.2) lattice 0.20-44 2021-05-02 [2] CRAN (R 4.1.0) lifecycle 1.0.0 2021-02-15 [1] standard (@1.0.0) magrittr 2.0.1 2020-11-17 [1] standard (@2.0.1) markdown 1.1 2019-08-07 [1] standard (@1.1) MASS 7.3-54 2021-05-03 [2] CRAN (R 4.1.0) Matrix 1.3-3 2021-05-04 [2] CRAN (R 4.1.0) mgcv 1.8-35 2021-04-18 [2] CRAN (R 4.1.0) mime 0.10 2021-02-13 [1] standard (@0.10) munsell 0.5.0 2018-06-12 [1] standard (@0.5.0) nlme 3.1-152 2021-02-04 [2] CRAN (R 4.1.0) pillar 1.6.1 2021-05-16 [1] standard (@1.6.1) pkgconfig 2.0.3 2019-09-22 [1] standard (@2.0.3) R6 2.5.0 2020-10-28 [1] standard (@2.5.0) rappdirs 0.3.3 2021-01-31 [1] standard (@0.3.3) RColorBrewer 1.1-2 2014-12-07 [1] standard (@1.1-2) rlang 0.4.11 2021-04-30 [1] standard (@0.4.11) rmarkdown 2.8.6 2021-06-03 [1] local rstudioapi 0.13 2020-11-12 [1] standard (@0.13) scales 1.1.1 2020-05-11 [1] standard (@1.1.1) stringi 1.6.2 2021-05-17 [1] standard (@1.6.2) stringr 1.4.0 2019-02-10 [1] standard (@1.4.0) V thematic 0.1.2 2021-06-03 [1] Github (rstudio/thematic@be612e5) tibble 3.1.2 2021-05-16 [1] standard (@3.1.2) tinytex 0.32 2021-05-29 [1] standard (@0.32) utf8 1.2.1 2021-03-12 [1] standard (@1.2.1) vctrs 0.3.8 2021-04-29 [1] standard (@0.3.8) viridisLite 0.4.0 2021-04-13 [1] standard (@0.4.0) withr 2.4.2 2021-04-18 [1] standard (@2.4.2) xfun 0.23 2021-05-15 [1] standard (@0.23) yaml 2.2.1 2020-02-01 [1] standard (@2.2.1) [1] C:/Users/chris/Documents/R/win-library/4.1 [2] C:/Program Files/R/R-4.1.0/library V -- Loaded and on-disk version mismatch. ```


Have you tried reinstall the packages ? Do you get the issue with their CRAN version too ?

I also simplified the example and use a dark theme to see better that thematic is working

---
title: "Untitled" 
output: 
  html_document:
    theme:
      bootswatch: darkly
      base_font:
        google: Open Sans
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, dev = "svg")
library(ggplot2)
thematic::thematic_rmd(font = "auto")

Chart A

ggplot(iris, (aes(Sepal.Width, Sepal.Length))) +
  geom_point()
py9mrg commented 3 years ago

Hello @cderv , hmmm that's weird - and I have the same problem with your simplified example. Yes I was originally on all the CRAN versions when the problem first arose. Then tried updating to development versions (and older versions, too) and same problem. Maybe it is something about my installed packages. I might try a complete reinstall of R and packages and see how that works. Will get back to you, thanks for the info.

py9mrg commented 3 years ago

Hello again @cderv . Ok so I did a complete fresh install (R and all packages) and it all worked fine. I downgraded, upgraded, deleted and reinstalled all the explicitly called ones for 2 hours earlier and nothing helped - must have been one of the dependencies that I hadn't tried updating I suppose. Sorry for wasting your time, but thank you - I wouldn't have been able to find the issue without you checking it works your end.

github-actions[bot] commented 2 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.