[R] Getting R graphics into MS Word (more)

Guido Masarotto guido at hal.stat.unipd.it
Tue Jul 27 11:02:15 CEST 1999


On Fri, Jul 23, 1999 at 11:19:46AM +0100, tra wrote:
> 
> To demonstrate the problem, I run the program:
> 
> > win.graph(width=5, height=3)
> > data(women)
> > plot(women)
> 
> Then, in the graph window, I select the command
> Save as metafile
> using the right mouse button, and save the file in c:\temp\women2.emf
> 
> Then, in Microsoft Word (97 SR 2) , I can import this file using
> Insert/Picture/FromFile
> 
> When I do this, the picture is truncated to about 70% of its correct
> width and height.
> 
> I have looked at the metafile produced by R, and can make it import
> correctly into Word by increasing the FrameRight and FrameBottom
> parameters (at offset 0020x and 0024x in the file) by a factor of 1.49.
> 
> Using Copy as Metafile and the Paste in Word does the same as using an
> intermediate file, but with no chance to view or edit the emf file
> header.
> 
> It looks to me as if there is a problem, either in the way that R
> calculates the Frame or Scaling parameters, or in the way that the Word
> import filter handles them.
> 

  I think I got the point and, as Tim confirmed using an updated R.dll,
  fixed it in the R-devel source.

  Problem was that Windows and R disagreed on the number of "reference
  pixels" of the metafile when metric information reported by Windows
  are inconsistent,i.e., Windows seems to compute the number of reference
  pixels using (number of pixels) and (dimension in mm of the screen),
  I used (pixels for inch) and on some systems, like Tim one,
               ((mm for inch)*wp)/wmm != ppi
  where wp  = screen dimension in pixels,
        wmm = screen dimension in mm,
        ppi = pixels for inch.
  Just to give an example on Tim machine, rigth side was around 65,
  while left one was 96, which explain the 1.49 factor empirically
  determined by Tim.

  Strangely enough (pure Microsoft style?), the not coherent values 
  for wp, wmm and ppi are all got from the same Win32 API function.

  Thanks to Tim Auton and Partha Bagchi for helping me in testing.

  guido  
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list