1 Reply Latest reply: Feb 7, 2018 2:26 AM by Josefine Stål RSS

    Passing data to R within script load statement

    giulio cecco


      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.




          LOAD observation,

               [sepal length] as sepLen,

               [sepal width] as sepWid,

               [petal length] as petLen,

               [petal width] as petWid,

               [iris species]



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





          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.