[R-SIG-Finance] a concern about blotter (and RStudio)

Doug Edmunds dougedmunds at gmail.com
Mon Jun 4 02:09:29 CEST 2012


Checking the box in RStudio next to blotter
runs this code:
library(blotter) and also creates a hidden object,
.blotter

.blotter is reported as something like this
<environment: 0x0000000009811058>   #numbers will vary

RStudio's "clear all" button removes the .blotter object.
It calls rm(list=ls(all.names=TRUE)).

Without .blotter, the blotter demo's won't work.

But detaching and reattaching the blotter package
(by unchecking/rechecking the box) does not re-generate
the .blotter object. Unchecking the box calls
detach("package:blotter") with a default of unload=FALSE.

In order to create a NEW .blotter object you need
to call detach("package:blotter", unload=TRUE).
Then if there was no .blotter object, a new one will
be generated with library(blotter).

However, library(blotter) will NOT create a new .blotter object unless 
the previous one has been removed.  This is not a concern so long
as the namespace has not been unloaded, but it is a concern if
the namespace has been unloaded.

Concern:
If the namespace is unloaded, and the old .blotter object
is NOT removed, when library(blotter) is again called, it
will create a new namespace, but it does not update
the .blotter object.  The memory location, e.g.,
<environment: 0x0000000009811058> will not change, even
though there is a different namespace.

What is the .blotter object is used for?
If it is intended to point to the namespace, then there is
a concern that it will corrupt data, by pointing to an
area of memory that was freed when the old namespace was
unloaded.

-dae



More information about the R-SIG-Finance mailing list