# Displaying a list of percentage values according to their classification

I have a list of percentages as follows:

percent =
{21.15, 42.3, 57.68, 73.06, 84.6, 90.37, 96.14, 99.99, 99.99, 99.99, 99.99}


I want to classify these percentages into categories A, B and C. When a value is in the range 0% - 85%, it is A; when it in the range 85% - 95%, it is B; when it in the range 95% - 100%, it is C.

For example: elements 1, 2, 3 and 4 of percent should all be classified into the A category.

How might I produce a TableForm showing all the elements in percent displayed according to category?

percent =
{21.15, 42.3, 57.68, 73.06, 84.6, 90.37, 96.14, 99.99, 99.99, 99.99, 99.99};

{{"A", "B", "C"},
GatherBy[percent, {# <= 85, # <= 95, # <= 100} &]} // TableForm


This can also be written as

{{"A", "B", "C"},
GatherBy[percent, Thread[# <= {85, 95, 100}] &]} // TableForm

• Elegant solution! Aug 2, 2015 at 14:29

Depending on how you want the table aligned, you could use

percent =
{21.15, 42.3, 57.68, 73.06, 84.6, 90.37, 96.14, 99.99, 99.99, 99.99, 99.99};

TableForm[BinLists[percent, {{0., 85., 95., 100.}}],

TableForm[{{"A", "B", "C"}, BinLists[percent, {{0., 85., 95., 100.}}]},