Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the proportion of times that each distinct element appears in a list
| ResourceFunction["Proportions"][list] gives an association whose keys are the distinct elements of list, and whose values give the proportion of times those elements appear in list. | 
Find the proportions of times that each element appears in a list:
| In[1]:= | ![ResourceFunction["Proportions"][{a, b, c, a}]](https://www.wolframcloud.com/obj/resourcesystem/images/4ef/4ef6d7aa-b945-488a-9528-82adf386af1d/4f3133ca59b8be07.png) | 
| Out[1]= |  | 
Use with an Association:
| In[2]:= | ![ResourceFunction["Proportions"][<|a -> x, b -> y, c -> z, d -> y|>]](https://www.wolframcloud.com/obj/resourcesystem/images/4ef/4ef6d7aa-b945-488a-9528-82adf386af1d/0ce73451c9bd5829.png) | 
| Out[2]= |  | 
See how common each character is in a body of text:
| In[3]:= | ![ResourceFunction["Proportions"][
   Characters[ResourceData["Gettysburg Address"]]] // ReverseSort // N](https://www.wolframcloud.com/obj/resourcesystem/images/4ef/4ef6d7aa-b945-488a-9528-82adf386af1d/5fb4fb818422ac00.png) | 
| Out[3]= |  | 
Check for common words:
| In[4]:= | ![p = TakeLargest[
  N[ResourceFunction["Proportions"][
    TextWords[ResourceData["On the Origin of Species"]]]], 20]](https://www.wolframcloud.com/obj/resourcesystem/images/4ef/4ef6d7aa-b945-488a-9528-82adf386af1d/29fc82912e61539a.png) | 
| Out[4]= |  | 
| In[5]:= | ![BarChart[Reverse[p], ChartLabels -> Automatic, BarOrigin -> Left]](https://www.wolframcloud.com/obj/resourcesystem/images/4ef/4ef6d7aa-b945-488a-9528-82adf386af1d/11ad75df4bd4a226.png) | 
| Out[5]= |  | 
Visualize in a WordCloud:
| In[6]:= | ![WordCloud[p]](https://www.wolframcloud.com/obj/resourcesystem/images/4ef/4ef6d7aa-b945-488a-9528-82adf386af1d/337ec08bf260ef12.png) | 
| Out[6]= |  | 
Proportions is similar to Counts:
| In[7]:= | ![ResourceFunction["Proportions"][{a, b, c, a}]](https://www.wolframcloud.com/obj/resourcesystem/images/4ef/4ef6d7aa-b945-488a-9528-82adf386af1d/3fc23eccfd793102.png) | 
| Out[7]= |  | 
| In[8]:= | ![Counts[{a, b, c, a}]](https://www.wolframcloud.com/obj/resourcesystem/images/4ef/4ef6d7aa-b945-488a-9528-82adf386af1d/5e8e711d97270093.png) | 
| Out[8]= |  | 
| In[9]:= |  | 
| Out[9]= |  | 
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License