<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: QlikView and R: how to pass/receive data in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/QlikView-and-R-how-to-pass-receive-data/m-p/1551803#M14143</link>
    <description>&lt;P&gt;Hi, did you ever get an answer on this?&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2019 13:54:37 GMT</pubDate>
    <dc:creator>lorenzoconforti</dc:creator>
    <dc:date>2019-03-04T13:54:37Z</dc:date>
    <item>
      <title>QlikView and R: how to pass/receive data</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/QlikView-and-R-how-to-pass-receive-data/m-p/17067#M14142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;Hi Qlik aficionados,&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;I am currently trying to implement the Iris Cluster example in Qlikview.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Basically, it consists of an input dataset with the following fields: &lt;EM&gt;Observation, Sepal Length, Sepal Width, Petal Length, Petal Width, Iris Species&lt;/EM&gt;.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;I need to call the R function kmeans in order to group irises into 3 clusters, based on the information about petal and sepal dimensions.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;I created a table chart, using &lt;EM&gt;Observation&lt;/EM&gt; as dimension, and&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;R.ScriptEval('kmeans(cbind(q$petLen, q$petWid, q$sepLen, q$sepWid), 3, nstart = 20)$cluster', petLen, petWid, sepLen, sepWid)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;as the expression. This works wonderfully!&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Now, I want to create a scatter chart, assigning a color to each observation, according to the cluster it belongs to.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;So, I set &lt;EM&gt;Observation&lt;/EM&gt; as dimension, &lt;EM&gt;Petal Length&lt;/EM&gt; as first expression (x-axis) and &lt;EM&gt;Petal Width&lt;/EM&gt; as second expression (y-axes). Then, on the x-axis background properties, I set the following rule:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;if (R.ScriptEval('kmeans(cbind(q$petLen, q$petWid,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;q$sepLen, q$sepWid),3, nstart = 20)$cluster', petLen, petWid, sepLen, sepWid)=1, rgb(200, 12, 45))&lt;/SPAN&gt;.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;For simplicity, here I avoided nested IFs. For the moment, the idea is to set the color only for the &lt;EM&gt;Observations&lt;/EM&gt; belonging to cluster 1.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Doing this, I get the error message "Allocated memory exceeded" on the scatter plot, while SSEtoRserve says "more cluster centers than distinct data points".&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;My explanation of this is that Qlikview is passing the data to R one record at a time. Therefore, R can't calculate 3 clusters out of a single line of data. This is also confirmed by the fact that if I set the clusters variable to 1, it works.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;So, I think that the correct question is: How can I pass my variables to R as a whole? I mean, passing the entire variable array for petLen, petWid, sepLen, sepWid, and not the points one by one.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;And also, why is the same function working correctly with the table chart?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Sorry for the length of the post, but I hope this is clear. I am rather new with Qlikview, and I am aware that it is very likely that &lt;SPAN style="font-size: 10pt;"&gt;I am missing some importan and basic detail about the way Qlikview uses data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2024 08:47:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/QlikView-and-R-how-to-pass-receive-data/m-p/17067#M14142</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T08:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: QlikView and R: how to pass/receive data</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/QlikView-and-R-how-to-pass-receive-data/m-p/1551803#M14143</link>
      <description>&lt;P&gt;Hi, did you ever get an answer on this?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 13:54:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/QlikView-and-R-how-to-pass-receive-data/m-p/1551803#M14143</guid>
      <dc:creator>lorenzoconforti</dc:creator>
      <dc:date>2019-03-04T13:54:37Z</dc:date>
    </item>
  </channel>
</rss>

