Without looking further into the R-script itself my guess would be that you're trying to use a tensor function (since you're using ScriptEvalExStr) instead of an aggregation. KPI objects only allow a single value to be returned. Does your function return multiple values? If so, try using a line chart or similar.
You are right, above expression returns multiple values. I'm looking to convert to a KPI expression where it results sum of forecast results for 15 future months.
Example: I have 2 years historical sales data by Year Month and using Holt Winters model, i want to plot the data data in a line chart, which i was able to do that using "Analytics Tool Box" extension. But i need to show the sum of forecast results in a KPi object. I don't have to use the Analytics toolbox, just need an expression where it AGGREGATES using HOLT WINTERS model.
I'm not sure exactly what you want to sum if it's the mean, upper, lower or other. But what I would do at first is to change the function to ScriptAggr and second, remove the json part (which I think is only needed for the "Analytics Tool Box" extension). What you want there instead is the sum of your choice, as an example, I used "sum(res$mean)", which you should change according to your preference. Unfortunately, I haven't been able to test the code, but hopefully, this will help you going forward.