Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Luigi8
Contributor
Contributor

SSE plugin with R

Hi everyone,

I have connected Qlik sense with R and have successfully obtained many correct outputs (always one value despite the fact that I need a table but I was planning to get one item by one) .

This is the info I need to get, average and group info for each season:

Luigi8_3-1643746451802.png

However, I need to get the results for a Tukey test and I seem to be close but can't figure out how to get it.

I have tried this code in R and I get the desired outcome:

x <- unlist(Datos_anova["Total Solids (%)"]);
y <- unlist(Datos_anova["Estación"]);
datos.lm <- lm(x ~ y);
datos.av <- aov(datos.lm);
a <- names(aov(lm(x ~ y))$model)[2];
tukey.test2 <- HSD.test(datos.av, trt = a);
rownames(tukey.test2$groups)[1]

Luigi8_0-1643745962297.png

I converted this code in qlik to the following one:

R.ScriptAggrStr(' x <- q$Invest; y <- q$RegInnen; datos.lm <- lm(x ~ y); datos.av <- aov(datos.lm); a <- names(aov(lm(x ~ y))$model)[2]; tukey.test2 <- HSD.test(datos.av, trt = a); toString(rownames(tukey.test2$groups)[1])'
, [Total Solids (%)] as Invest, [Estación] as RegInnen)

But the output is an error:

Luigi8_1-1643746056287.png

When debugging my code I think the problem is in the trt argument as I got the name of the dimension from aov that needs to be passed to the trt argument correctly with the following code:

R.ScriptAggrStr('x <- q$Invest;y <- q$RegInnen;datos.lm <- lm(x ~ y);datos.av <- aov(datos.lm);a <- names(aov(lm(x ~ y))$model)[2];toString(a)'
, [Total Solids (%)] as Invest, [Estación] as RegInnen)

And I get the correct output:

Luigi8_2-1643746247874.png

Does anybody know what can I do in order to get this up and running?

Thanks in advance,

Best regards,

 

 

Labels (2)
1 Reply
Luigi8
Contributor
Contributor
Author

Hi, 

I have found more information and it seems that it is not finding the function as you can see in the image below the first attempt is with the code as described and then in the second one I have also included the load of the library but I still got the same error:

Luigi8_0-1643829247659.png

The package is installed and in R studio it works perfectly. I have also tried adding at the beginning of the code in qlik "install.packages("agricolae")" but it won't work.

 

 

 

Thanks in advance,

Regards,