Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Group small values in an association into a single category
ResourceFunction["AggregateSmallest"][assoc,x] sums values below x in Association assoc into a single number. | |
ResourceFunction["AggregateSmallest"][assoc,Scaled[factor]] sums small values in Association assoc into a single category no larger than a proportion factor of the total. |
Group all keys with values of 1 or less into a new "Other" key:
In[1]:= |
|
Out[1]= |
|
Group small values into an "Other" category that contains up to 50% of the total:
In[2]:= |
|
Out[2]= |
|
AggregateSmallest is designed to simplify the result of Counts. For example, this PieChart is unreadable for infrequent categories:
In[3]:= |
|
Out[3]= |
|
Aggregating 20% of the data makes the pie chart simpler:
In[4]:= |
|
Out[4]= |
|
If only one value meets the criterion, then no change is made:
In[5]:= |
|
Out[5]= |
|
Use a different name for the replacement key:
In[6]:= |
|
Out[6]= |
|
This work is licensed under a Creative Commons Attribution 4.0 International License