
Re: Drawing a straight line through points using R
Steve Dark Dec 5, 2016 9:37 AM (in response to Steve Dark )Just found someone that knows a bit of R in the building, have come up with this:
R.ScriptEval('lm(.arg2~.arg1)$fitted.values',Dim,Value)
And this:
R.ScriptEval('
a=.arg1
b=.arg2
lm1=lm(b~a)
predict(lm1,data.frame(a=seq(1,200,1)))
',Dim,Value)
Both seem to work well.

Re: Drawing a straight line through points using R
Martin Curtis Jan 25, 2017 1:05 PM (in response to Steve Dark )Thanks for posting this Steve  very helpful for jumpstarting the process.
Martin

Re: Drawing a straight line through points using R
Yves Ndjoli Feb 10, 2017 7:14 AM (in response to Steve Dark )Hi Steve,
Do you have any idea to calculate R² (R.squared)
Thanks!

Re: Drawing a straight line through points using R
Steve Dark Feb 10, 2017 10:11 AM (in response to Yves Ndjoli )Hi Yves, What is R in this context? Is it a field? If so it is just R*R. If you are aggregating you will need a sum around it, e.g. sum(R*R).
Sorry if I have missed the point?

Re: Drawing a straight line through points using R
Yves Ndjoli Feb 10, 2017 10:34 AM (in response to Steve Dark )Hi Steve,
R² ist a coefficient(variance) of regression in statistic,
you can use for it the function Linest_R2 in Qlik and in R: summary(lm(a~b))$r.squared. I tried to calculate this measure in a KPIChart with R but i didn't get it

Re: Drawing a straight line through points using R
Steve Dark Feb 10, 2017 3:21 PM (in response to Yves Ndjoli )I thought I was probably missing something  should have taken the time to Google, it's been one of those days though.
Have you got any output from R coming into your app? Does the simple straight line work for you?





Re: Drawing a straight line through points using R
Brian MacDonald Dec 7, 2016 10:37 AM (in response to Steve Dark )What extension are you using that gives you the ability to evaluate R scripts from QS?

Re: Drawing a straight line through points using R
Steve Dark Dec 7, 2016 4:36 PM (in response to Brian MacDonald)It's beta functionality, which is in the product already but is not publicly documented. You also need to install a plug in which is not yet publicly available.
Hopefully it will be ready for primetime soon, and I will try to remember to post back to this thread when it is.
Steve
Re: Drawing a straight line through points using R
Brian MacDonald Dec 8, 2016 4:08 PM (in response to Steve Dark )Please do.

