Function Repository Resource:

Rarest

Source Notebook

The rarest elements in a list

Contributed by: Arnoud Buzing

ResourceFunction["Rarest"][list]

gives a list of elements that are the rarest in list.

ResourceFunction["Rarest"][list,n]

gives a list of the n rarest elements in list.

Details and Options

When n is given, the rarest elements are taken in the order they appear in list.
UpTo[n] is supported, returning as many elements as are available if there are fewer than n.

Examples

Basic Examples (3) 

Find the rarest elements:

In[1]:=
ResourceFunction["Rarest"][{1, a, 2, "Hello", 2, 1, 3}]
Out[1]=

Find the three rarest elements:

In[2]:=
ResourceFunction["Rarest"][RandomInteger[10, 1000], 3]
Out[2]=

Find where you can avoid UFO sightings:

In[3]:=
ResourceFunction["Rarest"][
 Normal[ResourceData["UFO Sightings 2015"][All, "State"]], 10]
Out[3]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 12 October 2018

License Information