Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:
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]
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:
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:
Does anybody know what can I do in order to get this up and running?
Thanks in advance,
Best regards,
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:
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,