[R-SIG-Finance] An easy way to run the quantstrat faber.R demo within an R function?

Mark Knecht markknecht at gmail.com
Thu Sep 11 15:11:08 CEST 2014


On Thu, Sep 11, 2014 at 5:26 AM, Andre Mikulec
<andre_mikulec at hotmail.com> wrote:
>
>
> Hi,
>
> I am trying to run the faber.R demo within a function
>
> Here is the url
> https://r-forge.r-project.org/scm/viewvc.php/pkg/quantstrat/demo/faber.R?view=markup&root=blotter
>
>
> Within a function, when the 'faber.R code reaches initPortf() the following error is thrown.
>
>
> Error in exists(paste("portfolio", name, sep = "."), envir = .blotter,  :
>
>   object '.blotter' not found
>

When running R-Studio in the upper right there's a 'Clear' button
which gives you an additional checked option to clear hidden objects.
If you have that selected then all the environments, like blotter, are
deleted and this sort of error occurrs WRT blotter. If blotter exists
then

ls(envir=.blotter)

will show that it's there and what's in it. If it's not there then
I've fixed it in the past using

.blotter <- new.env()

to recreate it.

HTH,
Mark



More information about the R-SIG-Finance mailing list