Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a non-numerical data, let say

data = Table[RandomChoice[{0.2, 0.3, 0.25, 0.15, 0.1} -> {"A", "B", "C", "D", "E"}], {500}];

and i want to make a histogram for this data. My solution so far

datanew = data;
label = Sort@DeleteDuplicates[data];
Do[datanew = ReplaceAll[datanew, label[[i]] -> i], {i, 1, Length[label]}]
Histogram[datanew, Ticks -> {None, Automatic}, ChartLabels -> {None, Placed[label, Below]}]

Is there any better way to do this? Thank you.

share|improve this question
    
Have you tried anything already? Please post code to show what you want and where you are stuck. –  Yves Klett Oct 16 '13 at 13:52

1 Answer 1

up vote 5 down vote accepted
tallydata = SortBy[Tally[data], First];
BarChart[tallydata[[All, 2]], ChartLabels -> (tallydata[[All, 1]])]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.