Advanced Forecasting with R

Comments

7 comments

  • Avatar
    Hamza Jap-Tjong

    Hi Artem,

    Could you maybe help me out? When using the script, I keep getting the following error:

     

    Failed to execute the R model - Error in source("C:/Users/user/Documents/forecast.R") :
    C:/Users/user/Documents/forecast.R:5:23: unexpected input
    4: df3<-data.frame(fcastValues=truncArgs)
    5: mySeries = ts(df3[,

     

  • Avatar
    Artem Yevtushenko

    Hi Hamza,

    The script uses a placeholder directory and Rscript name.

    Once you've written your model function you can save it to an R script and then reference the function from the Sisense function editor.

    In the example above, I created an R script with a function module and then called it using the source command.

    Does this help?

    Cheers
    Artem

  • Avatar
    Hamza Jap-Tjong

    The reference to the file is (coincidentally) the same. 

     

    The error persist indicating that the input is unexpected. 

  • Avatar
    Artem Yevtushenko

    Can you attach your RDouble formula?

    Considering the error is vague I would first test the function and forecasting model in R and make sure that it is returning appropriate results. Start simple by using a CSV with a single dimension's time series data and use that as the source of your R input. Run the model one line at a time and review the results in Rstudio's Environment Data and Values panel. This should give you a good idea of if your model is correct in the first place. Once validated you can bring the entire function body into the RDouble function and test by replacing your csv input with args[[1]]. If your output is correct you can package the R script into a function and Rscript file, confirm the file's permissions and reference it in RDouble. I've had different environments behave differently with the "/", so you may need to escape it appropriately with the double "//" syntax. Hope this helps!

    Cheers,
    Artem

  • Avatar
    Hamza Jap-Tjong

    Thanks Artem. I will try it with a regular CSV first

     

    Formula in Sisense:

    RDOUBLE(True,
    "save(args, file='C:/Users/gerimedica/Documents/log.txt');
    source('C:/Users/gerimedica/Documents/forecast.R');
    module (args[[1]]);"
    , [Average Units])

  • Avatar
    Artem Yevtushenko

    Good luck!

    Also, did you replace "Average Units" with a measure of your own?

  • Avatar
    Hamza Jap-Tjong

    I renamed the field to Units to keep it consistent

Please sign in to leave a comment.