# Showing Correlation (r) in Note of Interactive Scatterplot

Here is the idea:

Students explore a series of challenges (make the r value between __ and __) with scatterplots that they can adjust on a graph. Then as they change the graph, the r value (correlation coefficient) is changing in the note of the instructions.

Any ideas on how this could be done?

Here is an example activity that has a note in bold on where the value would be.

Create a variable in your note CL `r=g1.number(`r`)`. Then, you’ll be able to use the {#} button of the note panel to add it where “r=” in your note.

Also, you can save yourself some work next time by putting your coordinates into lists, X and Y, then:

``````s_x2=total(X^2)
s_y2=total(Y^2)
s_xy=total(XY)
s_x=total(X)
s_y=total(Y)
``````

There’s also an integrated best fit (i.e. for lists X and Y, `Y~mX+b`), but for some reason it wouldn’t let me access r that way, so I’d stick with your calculations.

Thanks so much for the help! I have a follow up question

You say, “*Then, you’ll be able to use the {#} button of the note panel to add it where “r=” in your note.”

My CL understanding is still in development. I’m not sure what this means yet. What do you mean by {#} symbol?

-TJ

Bottom right there’s a button. Any variables you create in the note CL can be accessed using that button, instead of using the CL to define the `content` sink (i.e. content of the note is written in the CL). Using the button makes things more visible in editing mode. Did you ever figure out how to access the built in `r` from a desmos linear regression? I certianly would like to be able to use that rather than create all the parts for hand-calculation of the correlation coefficient. I never tried to figure it out. Don’t know if anyone else has.

In the calculator,

corr(x1,y1)

Will return just the correlation coefficient. I have not tried doing that in CL, but other things, such as mod, work, even if you have to wrap them in simpleFunction.

2 Likes

I did see that if I have an x_list and a y_list already—even with draggable points—then desmos calculator function corr() calculates the Pearson coefficient. I just made an expression r=corr(x_list,y_list), and with that one line I have “r” as a value for CL in other slides.

r can just cause issues because of polar coordinates, so may want to use r1 or another variable entirely.

Very good. Thanks for the tip.

Has anyone found a way to pull the generated r^2 value from calculator regression? I’m creating an activity on exponential regression, so using corr(x1,y1) doesn’t work as a workaround.