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 what I have done to fix is insert the following code and tested running 1 within a function 2 within a lexical function 3 within R studio ( within a lexical function ) Just after the calls require(quantstrat) call required ( If I am running in a function ) I put the following code if(!is.null(sys.call(sys.parent()))) { if (!exists('.blotter' , envir=.GlobalEnv )) { .GlobalEnv$.blotter <- new.env() } if (!exists('.strategy', envir=.GlobalEnv )) { .GlobalEnv$.strategy <- new.env() } } Just after the calls getSymbols( . . . ) and optionally ( If I am running in a function ) I put in the following code. ( This does not affect the program ( but for consistency if nothing else ) ) (note: .getSymbols is not an environment ) if(!is.null(sys.call(sys.parent()))) { .GlobalEnv$.getSymbols <- .getSymbols } Just after the calls assign(symbol,x) call (required ( If I am running in a function ) I put in the following code. if(!is.null(sys.call(sys.parent()))) { assign(symbol,x, envir = .GlobalEnv) } If I am running the code through RStudio I surround any dev() OR chart.#() calls to prevent the following errors 1 dev() # Only one RStudio graphics device is permitted 2 chart # RStudio margins error I put the following cde wrapper if (!any(search() %in% "tools:rstudio")) { # ... } Does any other easier way exist, so I do not have to modify so much code? Thanks, Andre Mikulec andre_miku...@hotmail.com _______________________________________________ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.