Qlik Community

Qlik Server Side Extensions Discussions

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

yannick_c
New Contributor III

Return multiple columns in a table

Hello,

I'm using R.ScriptEval to add a column "Cluster" to the dataset Iris but I can't return 2 columns with Load * Extension.

I have the following error message :


Rserve error: The method or operation is not implemented.


I can only return 1 column. I tried to copy the same code as R_BasicExample.


My code :

[Iris]:

LOAD

[Id],

[SepalLengthCm] AS [sL],

[SepalWidthCm] AS [sl],

[PetalLengthCm] AS [pL],

[PetalWidthCm] AS [pl],

[Species] AS [Nom]

FROM [lib://Mes Data/Iris.csv]

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

[Cluster_NotOk_2_Col]:

Load *

Extension R.ScriptEval('q$cluster<-kmeans(cbind(q$sL,q$sl,q$pL,q$pl), centers = 3, nstart=20)$cluster;qRes <-data.frame(Cluster = q$cluster,Id = q$Id);qRes;',Iris{Id,sL,sl,pL,pl});

/*


[Cluster_Ok_1_Col]:

Load *

Extension R.ScriptEval('kmeans(q, centers = 3, nstart=20)$cluster;',Iris{sL,sl,pL,pl});


*/


If someone could help me or know the answer it would be nice

1 Solution

Accepted Solutions
yannick_c
New Contributor III

Re: Return multiple columns in a table

Ok, I just found the solution : my sse-r-plugin was not uptaded...

I have just downloaded the last version (v1.2.1.) and everything is alright

4 Replies
sandeep_roy
Contributor

Re: Return multiple columns in a table

Hello Yannick,

Can you send kmeans(cbind(q$sL,q$sl,q$pL,q$pl) ...with same columns name...Have you tried different column name?

Iris{Id,sL,sl,pL,pl}



yannick_c
New Contributor III

Re: Return multiple columns in a table

Different column name ? I am using the same name as my data

I don't understand what you mean

yannick_c
New Contributor III

Re: Return multiple columns in a table

Even the example from R_BasicExample with Titanic data doesn't run (I have the same error)

--

Titanic:

LOAD

    ID,

    pclass,

    survived,

    sex,

    "age",

    age_b,

    fare

FROM [lib://data/Titanic_data.csv]

(txt, utf8, embedded labels, delimiter is ',', msq);


// Return a table from R (in one call to to the R plugin) with two columns: SumOfRow, MulOfRow

SumAndMulOfRowFromRscript:

Load * Extension R.ScriptEval('q$SumOfRow = q$pclass+q$survived; q$MulOfRow = q$pclass*q$survived; qRes <- within(q, rm(pclass, survived)); qRes;', Titanic{ pclass, survived });

yannick_c
New Contributor III

Re: Return multiple columns in a table

Ok, I just found the solution : my sse-r-plugin was not uptaded...

I have just downloaded the last version (v1.2.1.) and everything is alright

Community Browser