Cannot load library svglite in R version 3.5.2

1.5k Views Asked by At

I want to export an SVG of an image I generated in ggplot2.

I've tried reinstalling and installing svglite and installing with dependencies = TRUE but I've still encountered the same error.

I'm using ggplot2, reshape, and svglite:

library(ggplot2)
library(reshape2)
library(svglite)

I've generated a variable containing my image:

image = ggplot(new.df) + geom_tile(aes(x=algorithm, y=name, fill=solved == "0")) + scale_x_discrete("") +
  scale_y_discrete(limits = rev(levels(df$name))) + scale_fill_manual(values = c("#33DD33", "#DD3333"), na.value="gray50") +
  theme(axis.text.x = element_text(angle = 90), legend.position="none")

and I execute the following line:

ggsave(file='~/Desktop/eterna100_51-100_ordered_TEST.svg', plot=image, device = "svg")

However, I get this error:

Error: package or namespace load failed for ‘svglite’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/gdtools/libs/gdtools.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/gdtools/libs/gdtools.so, 6): Library not loaded: /opt/X11/lib/libcairo.2.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/gdtools/libs/gdtools.so
  Reason: image not found
1

There are 1 best solutions below

0
On BEST ANSWER

You should download XQuartz https://www.xquartz.org/ and try again. svglite has some dependencies with XQuartz.