Hi Everyone,
I am struggling to draw a categorized histogram. Suppose we have a population of 100 cars. Cars are from Brand 1, Brand 2, Brand 3, and Brand 4 (Encoded numerical variable). The price of the car could be in three bins i.e. 50K-100K (bin 1), 100K-200K (bin 2), >200K (bin 3) (Encoded numerical variable).
Assume that we have 50 cars in first bin, 30 cars in second bin, and 20 cars in third bin.
Also, Assume out of 50 cars in first bin, 10 are from Brand 1.
Problem:
I want to draw a bar chart to show how much percentage of the cars within a bin are from Brand 1, Brand 2, Brand 3, and Brand 4 respectively. In other words, on x-axis the main variable will be bins and within bin I would like to have four bars. Hence, the first bar of bin 1 for Brand 1 should be 10/50 = 20 percent and so on.
I would highly appreciate if you can help me to code this by giving some example.
Regards,
I am struggling to draw a categorized histogram. Suppose we have a population of 100 cars. Cars are from Brand 1, Brand 2, Brand 3, and Brand 4 (Encoded numerical variable). The price of the car could be in three bins i.e. 50K-100K (bin 1), 100K-200K (bin 2), >200K (bin 3) (Encoded numerical variable).
Assume that we have 50 cars in first bin, 30 cars in second bin, and 20 cars in third bin.
Also, Assume out of 50 cars in first bin, 10 are from Brand 1.
Problem:
I want to draw a bar chart to show how much percentage of the cars within a bin are from Brand 1, Brand 2, Brand 3, and Brand 4 respectively. In other words, on x-axis the main variable will be bins and within bin I would like to have four bars. Hence, the first bar of bin 1 for Brand 1 should be 10/50 = 20 percent and so on.
I would highly appreciate if you can help me to code this by giving some example.
Regards,
Comment