# Aggregating Bi-variate Data in Desmos Activity Builder

I was creating an activity builder adaptation of a 3-Act plan called “Gas Station Ripoff” and I had a need to aggregate bivariate data across the whole class. [Original here. My version here.]

The only problem: aggregate only works on lists of numbers.

My work around was to add the following code:

What’s going on here? Well, “pump1point” is a mathematical input box. I get the latex content, and then parse this as an ordered pair object. Then, I get the x value (first coordinate). I then call the numericValue function so that aggregate can accept it.

Ultimately, what happens is I have a list called $G_1$ which contains the x-values for all the students. I do the same thing for the y-values, getting a list called $P_1$.

The advantage of doing it this way is that the CL eats the whole input at once, which means that student responses remain coupled, and in order when they are aggregated.

The final stage is to graph the list of points. After initializing each list, I simply put the following in the expression list of the graph:

The only drawback to this method is that students have to be precise about how they enter the data. It must be entered in the correct order. I’m not sure how robust parseOrderedPair is when there are missing or extra parentheses.

Please let me know if you find this useful, and comment with any questions. I am still learning the Computational Layer, so feedback from experts is appreciated.