0

I got a strange problem:

I have a display function (mainly relying on gglplot2) called draw(chain) taking as an argument a coda chain.

If I call into the R console:

 chain<-read.coda(#....name etc)
 pdf(paste(outDirectory,'/plot.pdf',sep=''))
 draw(chain);
 dev.off()

plot.pdf contains what expected. However, to do a similar job if I implement a function that encapsulates the saving:

 save<-function(name1,name2,outDirectory) 
 {
 chain<-read.coda(name1,name2)
 pdf(paste(outDirectory,'/plot.pdf',sep=''))
 draw(chain);
 dev.off()
 }

and simply call

   save(name1,name2,outDirectory)

in the R console : the resulting plot.pdf is unreable. I do not know how to clear this situation but really need it! If anyone have an idea, I appreciate.

I developed under R version 2.15.2, Mac version.

beuhbbb
  • 257
  • 3
  • 14
  • 1
    Please make your problem reproducible. See the [FAQ](http://stackoverflow.com/a/5963610/1412059) for advice on how to do that. – Roland Oct 09 '13 at 07:57
  • You should show (in addition to reproducible data) your function `draw`. There is no way of knowing what goes wrong without seeing the code for `draw`. – plannapus Oct 09 '13 at 08:21
  • 2
    Probably not the best idea to have a user-defined function called `save`, since that's already a base R function. – Thomas Oct 09 '13 at 08:22
  • 3
    Try `print(draw(chain))`. If that works, read http://stackoverflow.com/questions/2547306/generate-multiple-graphics-from-within-an-r-function – shadow Oct 09 '13 at 09:06

0 Answers0