6

To address an issue in my R package, I wish to try out an svglite graphics device for rendering ggplot plots:

knitr::opts_chunk$set(dev = "svglite")

But, if I do so, the {pkgdown} workflow fails (failure log) with the warning messages:

1: 'mode(bg)' differs between new and previous
     ==> NOT changing 'bg' 
2: 'mode(bg)' differs between new and previous
     ==> NOT changing 'bg' 

If I understand correctly, these warning messages are coming from par(), which is complaining about not being able to change the background colour (bg). But I am not explicitly calling par(), nor am I changing the background colour for the plot in question.

So I wish to know why exactly am I getting this error and how to resolve it?

Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
  • Please provide a minimum working example of your code, complete with the plot code. – StatsStudent Jan 17 '23 at 06:44
  • 1
    I can't tell exactly where your problem stemmed from. I figured out you're using the branch 'try_svglite' and that you've modded the device in `setup.R`. I found that `ggstatsplot.RMD` calls `setup.R`. Does that mean that this error is stemming from `ggbetweenstats`? I have ran a standard RMD and I cannot duplicate the problem. Can you provide a little more (or a lot more) details regarding what is happening and what's triggering the problem? What were you testing specifically? – Kat Jan 18 '23 at 17:27
  • can you edit your pkgdown yaml to have an R script to set the option `knitr::opts_chunk$set(dev = "svglite")` ? – Mike Jan 20 '23 at 16:14

1 Answers1

0

I think you have a font mismatch issue.

Download necessary font files, make sure in the source package and register the necessary them with package 'systemfonts' and function systemfonts::register_font(). This is the right thing to do for packages 'svglite', 'ragg' (and 'ggiraph').

It looks like you have "greek" variant on your machine, but not on the GA remote machine.

In your package, I would add a new 'Suggests' entry with gdtools that can help you download the font and register it seamlessly (disclaimer, I am the author, but I really think it makes things easier). And in the vignette, before any graph production with 'ragg' or 'svglite', add the following code:

gdtools::register_gfont(family = "Open Sans", subset = c("latin", "latin-ext", "greek"))
David Gohel
  • 9,180
  • 2
  • 16
  • 34