[rkward-devel] Problem with big objects
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Tue Oct 9 13:37:42 UTC 2007
On Tuesday 09 October 2007, I. Soumpasis wrote:
> > > Example:
> > > pdf("plot.pdf")
> > > xyplot(bla bla bla)
> > > dev.off()
> > >
> > > does not produces plots, although my data exists.
> >
> > You mean this is, when you run inside local()? No idea on this problem.
>
> Yeap. The same problem I have when I source the script file in R. If it
> helps.
Ok, I looked into this. The problem is that xyplot() does not actually print
the plot automatically, but merely produces a plot object. When you run the
statements one by one on the command line, the resulting object is
auto-printed, causing it to be sent to the pdf() device.
However, if you lump the calls together then no auto-printing happens. This is
not specific to local({}), but to anything that is evaluated in one go:
{
pdf("plot.pdf")
xyplot(...)
dev.off()
}
does not work either, same as source(). Solution: call print() or plot()
explicitely. E.g.:
local ({
pdf("plot.pdf")
print (xyplot(...))
dev.off()
})
will work as expected.
> This <<- symbol means that it makes a local variable global?
Yes, it's exactly like "<-" except it always assigns in the globalenv().
> Is this local
> function R's or rkward's function? I tried in R and it seems to work too.
Yes, it's an R base function. We just happen to use it a lot in RKWard.
> In RKWard it is really fast this way you are right. I will try to do it in
> my script. I just tried the example and it is really fast.
Another way (which is even better), is to put your code inside a function.
This, too will avoid the many assignments in globalenv().
Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20071009/6ce7c2a6/attachment.sig>
More information about the Rkward-devel
mailing list