[R] R: Including R plots in a Microsoft Word document

Liaw, Andy andy_liaw at merck.com
Sun Feb 22 16:56:25 CET 2004


> From: Ajay Shah

[snip] 
 
> Now for a (perhaps trivial) question: Several people said you have to
> do
> 
>   win.metafile("/myfile.wmf")
>   plot(1:10)
>   dev.off()                 <--------  this is essential
> 
> Why is the 3rd line essential? I have been feeding R programs into R
> using the command
> 
> $ R --vanilla < file.R
> 
> and I find things work just fine without having a dev.off()
> command. E.g. I have this program which seems to work fine:

Without closing the device explicitly with dev.off(), the file is not
closed.  If this is done in an interactive session, then

win.metafile("try.wmf")
plot(1:10)
[import the file into some application]

will give you empty graph.  This works for you inside a script because any
opened graphic devices are closed at the end of the execution.

HTH,
Andy

>   A <- read.table(
>          file="datafile.2",
>          na.strings=".",
>          
> col.names=c("date","dlinrchf","dlusdchf","dljpychf","dldemchf")
>        )
>   xfig(file="created.fig", onefile=TRUE, bg="LightSkyBlue", 
> width=5, height=3)
>   plot(A$dlusdchf, A$dlinrchf,
>                    xlab="USD/CHF returns",
>                    ylab="INR/CHF returns",
>                    col = "dark red")
> 
>      -ans.
> 
> -- 
> Ajay Shah                                                   Consultant
> ajayshah at mayin.org                      Department of Economic Affairs
> http://www.mayin.org/ajayshah           Ministry of Finance, New Delhi
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}




More information about the R-help mailing list