Is there a better alternative to an error? Perhaps return NA, with a warning? Or return an "empty" periodicity object, with a warning? An "empty" periodicity object could look something like what I recommended JJ implement for dygraphs:
Dear Joshua, I have just received the following error "Error in periodicity(R): can not calculate periodicity of 1 observation" and I am stuck. The point of this code is to run a backtest on the performance of an optimised portfolio. Is there any way you know how to go about this situation?
as @joshuaulrich pointed out, this isn't a support forum, but I'll give you a few other hints about where your problem might be. Your problem is most likely in how you are using PortfolioAnalytics.
You are specifying rebalancing on quarters. Typically you would do this using daily or weekly or monthly returns input data. See, for example
for a monthly return series.
You've further specified a training period of 60 periods (quarters). That would be 15 years of data before you generated your first portfolio and started rebalancing. Is this correct? Your first symbol: IUSA.L , looks as though it may only have been listed in 2002.