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
cancel
Showing results for 
Search instead for 
Did you mean: 
yannick_c
Partner - Contributor III
Partner - 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

Labels (2)
1 Solution

Accepted Solutions
yannick_c
Partner - Contributor III
Partner - Contributor III
Author

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

View solution in original post

4 Replies
Anonymous
Not applicable

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
Partner - Contributor III
Partner - Contributor III
Author

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

I don't understand what you mean

yannick_c
Partner - Contributor III
Partner - Contributor III
Author

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
Partner - Contributor III
Partner - Contributor III
Author

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