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

Brian G. Peterson brian at braverock.com
Mon Jun 4 02:32:04 CEST 2012


On 06/03/2012 07:09 PM, Doug Edmunds wrote:
> 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.

<...>


> 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.

I'm really *not* a fan of 'Clear all' in RStudio.  It's definitely not 
recommended good R programming practice, and is the equivalent of

rm(list = ls(all.names=TRUE))

even

rm(list = ls())

would be better, if still quite distasteful.

the .blotter environment is a storage container for transactions, 
portfolios, and account data.  All the 'tables' (data.frames, lists, and 
xts objects) needed by the blotter functions to keep track of everything 
are stored in this environment.

You can recreate an (empty) .blotter environment with this code:

.blotter <- new.env()

I just wish that RStudio would drop the sloppy 'Clear All' button 
(*especially* now that RStudio supports projects in separate directories 
and repositories), or at least allow a user option for whether to also 
clear hidden objects.

Regards,

   - Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list