Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Drawing a straight line through points using R

Hi,

I've got R integration set up with Qlik Sense Desktop and all seems to be working okay.  The example QVFs work fine and I have been able to send in two arguments and multiply them.

Unfortunately, I don't have any prior experience of using R.

Can anyone please advise how I can go about drawing a straight line through a set of values on a line chart?

Further to that, can someone advise how to extend that line n dimension values into future?

Thanks in advance.

Steve

1 Solution

Accepted Solutions
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

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.

View solution in original post

9 Replies
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

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.

Anonymous
Not applicable

What extension are you using that gives you the ability to evaluate R scripts from QS?

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

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 prime-time soon, and I will try to remember to post back to this thread when it is.


Steve

Anonymous
Not applicable

Please do.

martyginqo
Partner - Creator
Partner - Creator

Thanks for posting this Steve - very helpful for jumpstarting the process.

Martin

yvesqlik
Partner - Contributor III
Partner - Contributor III

Hi Steve,

Do you have any idea to calculate R² (R.squared)

Thanks!

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

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?

yvesqlik
Partner - Contributor III
Partner - Contributor III

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 KPI-Chart with R but i didn't get it

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP
Author

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?