Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
MVP & Luminary
MVP & Luminary

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
Highlighted
MVP & Luminary
MVP & Luminary

Re: Drawing a straight line through points using R

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
Highlighted
MVP & Luminary
MVP & Luminary

Re: Drawing a straight line through points using R

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

Highlighted
Creator
Creator

Re: Drawing a straight line through points using R

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

Highlighted
MVP & Luminary
MVP & Luminary

Re: Drawing a straight line through points using R

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

Highlighted
Creator
Creator

Re: Drawing a straight line through points using R

Please do.

Highlighted
Partner
Partner

Re: Drawing a straight line through points using R

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

Martin

Highlighted
Partner
Partner

Re: Drawing a straight line through points using R

Hi Steve,

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

Thanks!

Highlighted
MVP & Luminary
MVP & Luminary

Re: Drawing a straight line through points using R

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?

Highlighted
Partner
Partner

Re: Drawing a straight line through points using R

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

Highlighted
MVP & Luminary
MVP & Luminary

Re: Drawing a straight line through points using R

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?