Calculating/Displaying Correlation Coefficient from Aggregated Data

I am trying to calculate and display the correlation coefficient and the line of best fit from aggregated data (students input their foot length and height and a class scatterplot is created). I keep getting that the info for the line of best fit and the correlation coefficient is undefined, even when data is actually collected from an assigned class (I understand why it would come up as undefined without the actual data collected but am stumped as to why it’s not working when the data is actually aggregated). Can anyone help?

Your captures in button1 are named “a” and “b”, but your aggregate is trying to reference “x” and “y”, which don’t exist. A suggestion is to use a variable for the aggregate list in the button’s CL and referencing those variables for the lists in each graph, instead of individually calling the aggregate. For example:
In button1:

listX = aggregate(this.lastValue("a"))
listY = aggregate(this.lastValue("b"))

In each screens’ graph:

numberList("X"): b.script.listX
numberList("Y"): b.script.listY

This would ensure your aggregates match because they’re all in the button. Referencing those in the graphs will help you autocomplete, and you’d get CL errors if they were misnamed.

This wasn’t the fix I was looking for but it works now!