Qlik Community

Qlik Server Side Extensions Discussions

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

Announcements
Announcement: We have made updates to resolve a Page Not Found error. If you still get this error, please let us know in the Community Corner.
Highlighted
juliogiulio
New Contributor

Passing data to R within script load statement

Hello,

I am working on a QlikView project using R for advanced analytics tasks.

The example comes from https://community.qlik.com/docs/DOC-18787 and consists in reading data from the famous Iris database and classify each flower according to its petal and sepal dimensions.

In particular, I want to load flower data in the Script, and then send the columns that I've loaded to R, to calculate, for each record, the cluster it belongs to.

    IrisLoad:

    LOAD observation,

         [sepal length] as sepLen,

         [sepal width] as sepWid,

         [petal length] as petLen,

         [petal width] as petWid,

         [iris species]

    FROM

    Data\Iris.csv

    (txt, codepage is 1252, embedded labels, delimiter is ',', msq);

  

    SSELoad:

    Load

        observation,

    R.ScriptEval('kmeans(cbind(q$petLen, q$petWid, q$sepLen, q$sepWid), 3, nstart=20)$cluster', petLen, petWid, sepLen, sepWid) as IrisCluster                         

    Resident IrisLoad;

The thing is that I want to send to R the whole columns sepLen, sep Wid, petLen, petWid, and not one record per time, which is what happens with SSELoad.

My intention with SSELoad is to get 2 columns, one representing the observations, and one which correponds to their clustering group, based on the calculations made on the whole columns sepLen, sep Wid, petLen, petWid previously retrieved from the csv file.

So, how should I change SSELoad to achieve this? Or maybe I should do i in a ifferent way?

Thank you.

1 Reply
ost
New Contributor III

Re: Passing data to R within script load statement

Hi Giulio!

Unfortunately, there are some limitations using SSE in the QlikView load script.The behavior you are describing is working as intended. If SSE is used in a load statement, the function will be interpreted as a scalar function, unless it's an aggregation, and will only send one row of data at a time expecting one row of data back per call. We don't know when or if the functionality will be supported in QlikView.

If you are not limited to use QlikView I would recommend you to use Sense Feb 2018 when it's released. There we introduced a new load syntax `LOAD ... EXTENSION ...` for Table load using SSE (you can return multiple columns in a table) and all data is sent to the SSE plugin in a single call, just as you described. The github repository (GitHub - qlik-oss/server-side-extension: A Qlik server-side extension protocol for extending the Qli... ) is updated with examples and documentation of table load and the new functionality of sending TableDescriptions from the plugin describing the metadata of the returned table. (See the changelog for SSE v1.1.0 here: server-side-extension/CHANGELOG.md at master · qlik-oss/server-side-extension · GitHub)