R eps export and import into Word 2010

后端 未结 5 457
别跟我提以往
别跟我提以往 2020-12-18 06:29

I\'m having trouble with exporting eps files from R and importing into Word 2010.

I\'m using ggplot2 plots, eg

library(ggplot2)
p <-          


        
5条回答
  •  有刺的猬
    2020-12-18 06:54

    This worked for me... following advice in the postscript help page:

     postscript("RPlot.eps", height = 4, width = 4, horizontal = FALSE, onefile = FALSE,
                 paper = "special")
     library(ggplot2)
     p <- qplot(disp,hp,data=mtcars) + stat_smooth()
     p
    #geom_smooth: method="auto" and size of largest group is <1000, so using loess. Use 'method = x' to #change the smoothing method.
    #Warning message:
    #In grid.Call.graphics(L_polygon, x$x, x$y, index) :
    #  semi-transparency is not supported on this device: reported only once per page
     dev.off()
    #quartz 
    #     2 
    

    The funny stuff at the end puts you on notice that this is only a Mac-tested solution, so far anyway.

    Edit: I just tested it with R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows": Platform: i386-pc-mingw32/i386 (32-bit) and MS Word 2007 in Win XP and it worked. Commands were Insert/Picture.../select eps format/select file.

    Edit2: There is another method for saving besides directly using the postscript device. The savePlot method with an "eps" mode is available in Windows (but not in the Mac). I agree that the fonts are not as smooth as they appear on a Mac but I can discern no difference in quality between saving with savePlot and using save as from an interactive window.

    savePlot(filename = "Rplot2", type = "eps", device = dev.cur(), restoreConsole = TRUE)
    

    savePlot calls (.External(CsavePlot, device, filename, type, restoreConsole))

提交回复
热议问题