Hello all:
I have searched through the help files and I have been unsuccessful in
solving this problem.
I am trying to create a small wrapper function that will go around a
call to a plot function and create a windows metafile in the directory
and also write the name of the file to a text file. The purpose is to
efficiently bring a large number of plots into powerpoint. I am using
platform
i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 3.0
year 2006
month 04
day 24
svn rev 37909
language R
version.string Version 2.3.0 (2006-04-24)
I would like the function to handle trellis plots as well as regular
plots.
Here is the function.
plotSlide<-function(pltexpr){
expr<-as.expression(pltexpr)
numslide<-length(dir(pattern="wmf"))+1
fname<-paste("SG",numslide,".wmf",sep="")
dirlist<-dir(pattern="SlideList.txt")
if (length(dirlist)==1){
fs<-file("SlideList.txt",open="at")
write(paste(fname,"Graph",sep=","),file=fs)
close(fs)} else {
write(paste(fname,"Graph",sep=","),file="SlideList.txt")
}
# if(is.element(class(eval(expr)),"trellis")){
# trellis.device(device = win.metafile, theme = "col.whitebg", new
TRUE, retain = FALSE, file=fname,width=6,height=4)
# print(eval(expr))
# dev.off()
# return(fname)
# }
win.metafile(file=fname,width=6,height=4)
print(dev.cur())
eval(expr)
dev.off()
return(fname)
}
The function as displayed will write the regular graphics. If I
uncomment the commented lines it will write trellis graphics but will no
longer write the regular graphics. (I get a bunch of empty graphs - the
graph frame but no data). So it appears that when I evaluate the
expression to see if it is a trellis graph it no longer correctly
evaluates at the end of the function. Any advice would be most welcome.
Michael Conklin
Chief Methodologist - Advanced Analytics
MarketTools, Inc.
6465 Wayzata Blvd. Suite 170
Minneapolis, MN 55426
Tel: 952.417.4719 | Mobile:612.201.8978
Michael.Conklin@markettools.com <mailto:Michael.Conklin@markettools.com>
MarketTools(r) http://www.markettools.com
<http://www.markettools.com/>
This e-mail and any attachments may contain privileged, confidential or
proprietary information. If you are not the intended recipient, be aware
that any review, copying, or distribution of this e-mail or any
attachment is strictly prohibited. If you have received this e-mail in
error, please return it to the sender immediately, and permanently
delete the original and any copies from your system. Thank you for your
cooperation.
[[alternative HTML version deleted]]