Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More

QlikView and R Integration for Predictive Analytics Example

cancel
Showing results for 
Search instead for 
Did you mean: 
Brian_Bauer
Former Employee
Former Employee

QlikView and R Integration for Predictive Analytics Example

Last Update:

Feb 8, 2023 6:18:53 AM

Updated By:

Sonja_Bauernfeind

Created date:

Apr 2, 2013 5:16:51 PM

Attachments

If you have never thought about integrating predictive analytics and QlikView, may this article pique your interest on the topic.  If you have thought about the potential, but do not know how to get started, may this be the motivation to start your journey.

 

This demo example illustrates the art of the possible around the interoperability of the R statistics engine and QlikView 11 for enabling predictive algorithms within QlikView today.

 

R (http://www.r-project.org/) is a free software environment for statistical computing and graphics, which supports predictive modeling and scoring.  The example also introduces Rattle (Rattle: A Graphical User Interface for Data Mining using R -- http://rattle.togaware.com/).  Rattle was used to create the predictive model and generate the R code implemented within the example QlikView application.  The use of Rattle is not detailed here.  It is left up to you to explore.

 

The example assumes you understand R and how to create predictive models in R and how scoring works in R.  If you understand how to do those things in R and you know how QlikView works, this example should give you an idea of how:

  1. you could implement a compelling QlikView application for discovering trends in data as you have become used to with QlikView
  2. while adding the ability to predict outcomes using a proven, trained scoring model you have built in R
  3. and while showing actionable predicted outcomes at the point of decision

-- all without the end user having to leave QlikView.

 

As in the previous example posted by Elif Tutuk, "Integrating QV with R example kit.zip" (http://community.qlik.com/docs/DOC-2975), the example utilizes statconnDCOM.  A slightly different approach in this example overcomes a break in functionality introduced into that earlier example by the changing in the behavior of one of the COM API methods in the most recent releases of statconnDCOM.

 

The integration is done using QlikView's built-in VBScript support to interoperate with the DCOM-based API.  This is just one way to integrate with R.  With a little research you can discover other potential opportunities for R integration (e.g., OpenCPU).  Also, note that R is just one such example of a statistical engine being integrated with QlikView.  Other solutions, such as commercially available statistical engines or predictive scoring engines may also be integrated in similar ways.

 

To get started with this example, save the attached file, QlikView-R_Predictive_Demo.zip, to your system.  Open the zip file, and copy the enclosed folder (QlikView-R_Predictive_Demo) to a location of your choice.  The location is not important as the example is portable and has no dependency on being placed in a particular folder on your system. Now navigate into the folder you just extracted and find the document named “Qlikview-R Integration Demo 20170310.pdf”.  Open the document and follow the instructions step-by-step.

 

UPDATE (May 7, 2014):  I updated the installation document (Qlikview-R Integration Demo 20140421.pdf) to eliminate the RAndFriends installer as it has been unavailable for some time.  This edition of the document references R 3.1.0.  Hopefully the instructions will continue to be a good guide for subsequent versions as well.  I will continue to monitor for changes in R, statconnDCOM and other R components which could effect how the demo application works going forward.  The example QlikView application itself remains unchanged. It is a Personal Edition version, so you should be able to explore it with a licensed QlikView Desktop or the Personal Edition.  Thank you for your continued feedback on this demo.

 

UPDATE (September 21, 2015):  Everyone who has been seeing the message "The license that is embedded in this document is not valid":  I attached an updated version of QlikView-R_Predictive_Demo.zip‌.  Ensure you overwrite the old QVW with the new one in this package.  That is the only change.  Please forgive this looooong overdue update. 

 

UPDATE (October 9, 2016):  Updated the embedded license to work with QlikView Desktop Personal Edition.

 

UPDATE (February 2, 2017):  Updated the embedded license to work with QlikView Desktop Personal Edition.

 

UPDATE (March 10. 2017):  A dependency for this particular example is statconnDCOM from the team at autstat (http://www.autstat.com/).  If you wish to utilize statconnDCOM, you will need to contact autstat directly and purchase a license or request an evaluation license for testing.

 

 

Labels (1)
Comments
danielgargiulo
Partner - Creator
Partner - Creator

no solutions from me yet.

thanks

dan

Not applicable

I encountered the error as well and I determined it is because within the macro the export of the QlikView object always includes the Byte Order Mark at the beginning of the csv file (even though a charset of ascii is indicated).  So during the step in R which specifies the relevant variables from the dataset after the read of the exported file it fails because it cannot correctly find the 'record' column.  The only way I was able to get it to work was to export the original object to a temporary file name and then use a newly created function to convert the tmp file into the final ascii export csv file (function based on the answer posted in the post Ansi codification). I hope this helps.

agigliotti
Partner - Champion
Partner - Champion

Hello,

Fews days ago I upgraded the R system to version 3.0.1 from version 2.XX

After this I noted the staconnDCOM object, inside the QV document macro, doesn''t works anymore.

It fails at R.Init "R" statement !

How can I fix it ?

Is there another way to integrates QlikView with R ?

Please let me know.

Many thanks in advance.

Best Regards

Andrea

Brian_Bauer
Former Employee
Former Employee

Hello QlikCommunity:


I see some folks are having difficulty with the demo application and the newer versions of R.  So, I spent a some time looking at R v3.0.2 (most current version as of this writing) and the statconnDCOM API (3.5-1B2).  What I found is that some things changed in the interaction between R and the statconnDCOM API.  The QlikView demo application itself requires no changes. After uninstalling R 2.15.2 and installing R 3.0.2, I found the demo app didn’t work on my system, as others have reported.  I heard from one person that R v3.0.1 did not work with the statconnDCOM API, either. Ensure you have at least R v3.0.2.

The information contained herein assumes you are familiar with the “Qlikview-R Integration Demo 20130226.pdf” guide, used to set up the demo initially.  Rather than re-writing that initial set-up document right now (which I have on my todo list), I put this together to quickly get the information out about what I and others have done to get the R and statconnDCOM API working again.  As R or the API gets revised, we could see the connection between them being broken again.  The StatConnector Test utility (below) is a good tool to determine that is the problem, so you can troubleshoot accordingly.

Unfortunately, I learned the RAndFriends distribution is not available any longer.  Now we have to do some manual steps. Also, according to this information on how to install R for use with statconnDCOM –

http://homepage.univie.ac.at/erich.neuwirth/php/rcomwiki/doku.php?id=wiki:how_to_install

“R needs to be installed with the SDI display option (you are prompted for using either SDI or MDI during the custom installation of R). And you also need to tell R to write its registry entries during installation (you are prompted for that also).”

I set the SDI display option during the custom installation.  I am not convinced the SDI display option is critical for our purposes, as someone I know did not set it and has a functioning demo.  Better be safe and set it to SDI when you do a custom R installation, nonetheless. Also go ahead and select all the modules, including the Remote ones.  With respect to the write registry entries prompt, I don’t recall being prompted. If you are prompted, make sure to tell R to write its registry entries – like mentioned above.


If you need to re install statconnDCOM, you can find it here:  http://rcom.univie.ac.at/download.html.

1.jpg

I determined I was unable to connect to R via the API using the StatConnector Test utility found under Windows > Start > All Programs > statconn > DCOM > Server 01 - Basic Test.  I was seeing this when I clicked on R32:

2.jpg

I figured out I didn’t have rscproxy installed (which btw is listed as a requirement for statconnDCOM, above).  I installed it in the R console by running install.packages(“rscproxy”).  One person had difficulty with this step because for some reason they didn’t have write permission on the library folder under the R installation folder.  You should see a folder named rscproxy in the library folder.

3.jpg

After successfully having the rscproxy library in place I get this when clicking R32:

4.jpg

Remember to install Rattle into R as well for the demo app to work.


Finally, please ensure you set in your QlikView Desktop software the User Preferences for Export to ANSI encoding.

5.jpg

The QlikView application should now be able to communicate with R through the statconnDCOM API.

Thank you and best of luck.

-Brian

Not applicable

Thank you very very much Brian. I struggled with the application for 3 days but after going through each and every comment patiently I was able to run the example successfully. Thanks a ton !

Meanwhile, I will be working on few basic examples to further explore the integration of R with Qlikview. Will update you about the results.

Thanks, Tanmay.

Not applicable

Hey Brian,

I was able to execute the Predictive Analytics example you have provided. Thanks again for that !

So now was trying to perform some simple examples to get comfortable with the integration. But being an R guy, I could not understand much of the code in 'Edit Module' except R part. Thus, would request if you can provide some help document or manual which would help me in getting comfortable with QlikView and its integration with R. May be a simple example which selects two dimensions and gives average for the third dimension will really help.

Thanks for the help. Looking forward to your reply.

Best regards,

Tanmay

adamdavi3s
Master
Master

Hi Brian,

I am sorry to trouble you but I just can't get the statconn to work at all (using the basic test)

I've done a clean install of everything:

R x64 3.0.2 ensuring SDI and registry writing

statsconn 3.5-1

rattle (installed from R)

rscproxy (just installed package from R)

But it just doesn't seem to want to connect. I am at a loss I am afraid!

I'm new to R but not qlikview, I assume I don't need to load the rscproxy package as if I try this it just tells me it is in-use so assume it is working!

adamdavi3s
Master
Master

OK so my problem was obviously mis-matched versions.

No combination of R, STATSCON and rscproxy seemed to work for me, and I tried a LOT.

However after about an hour on google I finally found an old install of R and friends and hey presto, works a treat!

If anyone needs this in the future:

http://cgg.mff.cuni.cz/trac/morpho/export/2365/branches/CurveViewerBranch2/requirements/RandFriends/...

I will also be backing this up locally in case the install gets removed.

Brian_Bauer
Former Employee
Former Employee

Hello Tanmay,

I am not clear on where you want to do the calculations – in the QlikView application or in R.  If you wish to become better oriented to how to do things in QlikView itself – not using macros – take a look at the following.  We have free training resources available on the QlikView website:  http://www.qlik.com/us/services/training/free-training.  I suggest these selections:

  • Build Your First QlikView
  • QlikView Tutorial

If you want to do more in the Macro Editor with VBScript to reference objects in the QlikView application, here is documentation on the COM API:  “QlikView Core COM API Guide - Version 11” (http://community.qlik.com/docs/DOC-2640).


Lastly, the QlikCommunity is an excellent source for all manner of examples.  You can usually find something to help accomplish what you are looking to do.

Best Regards,

-Brian

Brian_Bauer
Former Employee
Former Employee

Hello Adam,

Hmm.  If you followed along, I don't know what could be the matter. Did you ensure the rscproxy folder is in the library folder under the R installed folder?

rscproxy.jpg

Also, the statconnDCOM NONCOMMERCIAL version is 32-bit.  Only the R32 button in the StatConnector Test will yield results.

-Brian

Version history
Last update:
‎2023-02-08 06:18 AM
Updated by: