在Ubuntu 10.04上从源代码安装R后,我遇到了保存ggplot生成图表的问题。
例如以下内容:
library(ggplot2)
head(diamonds)
p <- ggplot(data = diamonds, aes(x = carat, y = price, colour = cut)) + layer(geom = "point")
p <- p + layer(geom = "point")
ggsave("plot.svg")
结果:
Saving 7 x 7 in image
Warning messages:
1: In grDevices::svg(...) : unable to load shared object
'/app/vendor/R/lib64/R/library/grDevices/libs//cairo.so':
libpng15.so.15: cannot open shared object file: No such file or directory
2: In grDevices::svg(...) : failed to load cairo DLL
cairo.so出现在:/app/vendor/R/lib64/R/library/grDevices/libs/cairo.so
libpng15.so.15出现在:/app/vendor/libpng/lib/libpng15.so.15
运行功能()会产生:
> capabilities()
jpeg png tiff tcltk X11 aqua http/ftp sockets
TRUE TRUE TRUE FALSE FALSE FALSE TRUE TRUE
libxml fifo cledit iconv NLS profmem cairo
TRUE TRUE TRUE TRUE TRUE FALSE TRUE
我对这里可能出现的问题感到有点失落,也许这与我的libpng15.so.15文件的位置有关?