<br><br><div><span class="gmail_quote">2007/10/9, Thomas Friedrichsmeier <<a href="mailto:thomas.friedrichsmeier@ruhr-uni-bochum.de">thomas.friedrichsmeier@ruhr-uni-bochum.de</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Tuesday 09 October 2007, I. Soumpasis wrote:<br>> > > Example:<br>> > > pdf("plot.pdf")<br>> > > xyplot(bla bla bla)<br>> > > dev.off()<br>> > ><br>> > > does not produces plots, although my data exists.
<br>> ><br>> > You mean this is, when you run inside local()? No idea on this problem.<br>><br>> Yeap. The same problem I have when I source the script file in R. If it<br>> helps.<br><br>Ok, I looked into this. The problem is that xyplot() does not actually print
<br>the plot automatically, but merely produces a plot object. When you run the<br>statements one by one on the command line, the resulting object is<br>auto-printed, causing it to be sent to the pdf() device.<br><br>However, if you lump the calls together then no auto-printing happens. This is
<br>not specific to local({}), but to anything that is evaluated in one go:<br> {<br> pdf("plot.pdf")<br> xyplot(...)<br> dev.off()<br> }<br>does not work either, same as source(). Solution: call print() or plot()
<br>explicitely. E.g.:<br> local ({<br> pdf("plot.pdf")<br> print (xyplot(...))<br> dev.off()<br> })<br>will work as expected.<br><br>> This <<- symbol means that it makes a local variable global?
<br><br>Yes, it's exactly like "<-" except it always assigns in the globalenv().<br><br>> Is this local<br>> function R's or rkward's function? I tried in R and it seems to work too.<br><br>
Yes, it's an R base function. We just happen to use it a lot in RKWard.<br><br>> In RKWard it is really fast this way you are right. I will try to do it in<br>> my script. I just tried the example and it is really fast.
<br><br>Another way (which is even better), is to put your code inside a function.<br>This, too will avoid the many assignments in globalenv().</blockquote><div><br>Thanx Thomas! All these hints were really helpful.<br><br>
Really appreciate that.<br><br>When my scripts are finished and (hopefully) the results are published R RKWard and some function libraries will have a citation.<br><br>Kind Regards,<br>Ilias<br></div><br></div><br>