[R] Export a plot/figure to excel or word?

Steve Taylor steve.taylor at aut.ac.nz
Wed Mar 14 21:14:53 CET 2012


Oops, this uses one of my own functions %like%

"%like%" <- function(x,y) grepl(y,x,ignore=TRUE)

Here's an improved version of word.tif ...
word.tif <- function(filename="Word_Figure_%03d.tif", zoom=5, width=17, height=10, pointsize=10, ...) {
  if (!grepl("[.]ti[f]+$", filename,ignore.case=TRUE) filename = paste(filename,"tif",sep='.')
  tiff(filename=filename, res=96*zoom, width=width, height=height, units='cm', pointsize=pointsize, compression="lzw", ...)
}

Note the zoom, which creates high quality images by default. 

S

-----Original Message-----
From: Steve Taylor 
Sent: Thursday, 15 March 2012 9:01a
To: 'Aurelie Cosandey Godin'; r-help at r-project.org
Subject: RE: [R] Export a plot/figure to excel or word?

I have found the TIF format (with lossless compression) most suitable for inclusion in Word documents.  

Here's my function for producing a tif plot...

word.tif <- function(filename="Word_Figure.tif", zoom=5, res=96*zoom, width=17, height=10, pointsize=10, bg='white') {
  if (!filename %like% "[.]ti[f]+$") filename = paste(filename,"tif",sep='.')
  tiff(filename=filename, res=res, width=width, height=height, units='cm', pointsize=pointsize, bg=bg, compression="lzw") }

# usage...
word.tif('random normals', width=10, height=10)  # centimetres
plot(rnorm(100))
dev.off()


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Aurelie Cosandey Godin
Sent: Thursday, 15 March 2012 8:50a
To: r-help at r-project.org
Subject: [R] Export a plot/figure to excel or word?

Hi all,

I have created forest plots using the package "meta" that I submitted as pdf for publication. I just received an email from the editor asking me if I could send these files in an Excel or MS Word format such that they can treat them as tables with box plots.

I am not sure if I can do this... Is this possible? I've tried the capture.output command, but I get a blank MS Word document.

Thank you very much in advance,
Best,

Aurelie


Aurelie Cosandey-Godin
Ph.D. student, Department of Biology
Industrial Graduate Fellow, WWF-Canada

Dalhousie University | Biology Dept. | 1459 Oxford Street |Halifax, NS | Canada B3H 4R2
Phone: 1-902-494-2146 | cell: 1-902-412-3404 |Fax: 1-902-494-3736
Email: godina at dal.ca | Skype: aureliegodinco | Web: wormlab.biology.dal.ca
----------------------------------------------------------------------------------------------------------------------------------------------------
Want to learn more about sharks in Atlantic Canada? Visit ShARCC! www.atlanticsharks.org













	[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list