A pretty common requirement is to actually compute some basic statistics about your data. Most of the time those calculations happen on all the values in a specific column or a collection of columns, which is part of why we arrange our data in a column-wise manner. The result is always a single value, but it can be represented in two different ways. Depending on how your original dataset was set up, you might get two different types of values:
If you did not set the
true, you will just return a value (most likely a number) for any of the following calls.
If you set
sync:trueon your original dataset, you will get a
Miso.Dataset.Productfor any of the following calls. The Miso.Dataset.Product maintains a binding to the original Dataset and will know to recompute itself when changes occur to the underlying data. This does mean that you need to retrieve the value directly from this Miso.Dataset.Product object by calling
.val(). For example:You can edit the code in this block and rerun it.
Due to the way the data types work in Dataset, any non-numeric values that can't be cast to a number are ignored by these methods.
The following are custom methods that come pre-packaged with Dataset, although you can easily add your own!
Note that the
max can be computed on numeric columns but also time columns!
Note you can't add up dates, so don't try that one.
Adding your own
If you want to add your own computations to your dataset, take a look at
src/products.js for some examples (like
For example, if we wanted to implement a product that returned a random value from the dataset, you could do it like so: