R无法识别GhostScript嵌入eps图

Mar*_*les 5 r ghostscript eps

我正在尝试为期刊出版要求嵌入.eps文件.

我使用ggplot2创建我的情节:

p=ggplot(data=sim, aes(x=TIME,y=DV,group=ID))+
  theme_few()+
  geom_point(aes(shape=as.factor(SEASON2)),size=3,fill="white")+
  geom_point(aes(color=as.factor(AGE2),shape=as.factor(SEASON2)),size=3,fill="white",show_guide=F)+
  scale_shape_manual(name="Season",values=c(25,24))+
  geom_line(aes(color=as.factor(AGE2),linetype=as.factor(MODEL2)),size=0.75)+
  scale_linetype_manual(name="Model [Population]",values=c("dotted","solid"))+
  scale_color_manual(name="Age",values=as.vector(c(ggthemes_data$few$medium[5],ggthemes_data$few$medium[4])))+
  theme(legend.position="bottom",legend.direction="vertical",legend.box="horizontal")+
  guides(color=guide_legend(order=1), shape=guide_legend(order=2), linetype=guide_legend(order=3))+
  xlab("Clock time [hours]")+
  ylab("Testosterone levels [ng/dL]")+
  geom_hline(yintercept=300,linetype="dashed",color="black")
print(p)
Run Code Online (Sandbox Code Playgroud)

然后,我生成.eps

postscript(file.path(directory,"Script","Figure5.eps"),
           width=10,
           height=12.25,
           paper="a4",
           horizontal=T,
           onefile=TRUE)
print(p)
dev.off()
Run Code Online (Sandbox Code Playgroud)

当我尝试提交剧情时,这个.eps不被在线应用程序接受,因为我必须让ADQ Advisor可以使用这些字体.

为了做到这一点,我用过:

install.packages("extrafont")
library("extrafont")
font_import()
fonts()
loadfonts(device = "postscript") ## for postscript()

embed_fonts("./Figure5.eps", outfile = "./Figure5-embed.eps", options = "-dEPSCrop")

embedFonts(file="Figure5.eps",
          outfile="Figure5EMB.eps",
          options="-dEPSCrop")
Run Code Online (Sandbox Code Playgroud)

这两个函数都失败了,并给了我以下错误:

embedFonts出错(file ="Figure5.eps",outfile ="Figure5EMB.eps",:找不到GhostScript

我在以下路径中安装了GhostScript 9.18:C:\ Program Files(x86)\ gs\gs9.18

有什么建议?

Ken*_*enS 3

根据 R文档,您使用 R_GSCMD 环境变量设置 R 使用的 Ghostscript 可执行文件的位置,但搜索 PATH 失败。您是否已设置该环境变量,或者是否已将 Ghostscript 可执行文件的路径添加到 PATH 环境变量中?

另请注意R 开发人员邮件列表中的这个,以及这个。我不知道为什么文档认为有不同的可执行文件来查看和操作 PostScript/PDF 文件,这不是真的(尽管您可能想要使用不同的应用程序,例如 GSView,在 Ghostscript 显示设备上查看文件也可以工作,尽管更加粗糙)。