Given the following simple data set, what is the best way to average the values for the sets 0 25 53 and 80.
[["0", "148.5"],
["0", "146.5"],
["0", "148.6"],
["0", "202.3"],
["25", "145.7"],
["25", "145.5"],
["25", "147.4"],
["25", "147.3"],
["53", "150.4"],
["53", "147.6"],
["53", "147.8"],
["53", "215.4"],
["80", "150.4"],
["80", "149.4"],
["80", "148.0"],
["80", "149.9"]]
It’s simple enough with inject. I often implement a general group_by method in projects to help with stuff like this.
If data is large and performance matters consider using a numeric library or database if appropriate.