Qlik Community

Qlik Server Side Extensions Discussions

Discussion Board for collaboration on Server-Side Extensions and Advanced Analytics Integration.

Not applicable

Calendar fields and TimeSeries function in R

I'm doing a demo on R integration on Sense and I've come across a problem with ts( start=c()) function.

I can't get the start working in my dataset (I can drop the not wanted rows in load script), is there something I should take into consideration while generating the calendar for it to work with R timeseries functions?

So in short the problem is that I'd like the forecast function to start forecasting from a spesific year instead of from the first date.

Thx

here's the script for clarification:

R.ScriptEval('library(forecast);'&

    'data<-ts(na.omit(q$Variable1),frequency=12, start=c(1998,1));'&

    'fit<-auto.arima(data);'&

    'res<-forecast(fit, level=0.95, h=q$vForecastPeriods); '&

    'n <- length(q$Variable1); '&

    'fore <- append(q$Variable1[(q$vForecastPeriods - 1):n],res$mean,after= n - q$vForecastPeriods); '&

    'fore;',

    Sum(NoZerosco2) as Variable1,

    $(vForecastPeriods) as vForecastPeriods)

3 Replies
bvk
Contributor II

Re: Calendar fields and TimeSeries function in R

Hi Jokke,


You will need to create blank rows in Qlik Sense to fill with your forecast data.


Regards,

Bas.

Not applicable

Re: Calendar fields and TimeSeries function in R

So you're suggesting that I do this in load script and dump the results in a new dimension? And then use that as a calculation in graph etc?

bvk
Contributor II

Re: Calendar fields and TimeSeries function in R

You will need to generate rows in your data set with time dimension in the future but with empty data. When using the expression to do the calculation of your measure. The result of the expression will be used to create the chart.

Community Browser