0

I'm learning to use R, and I want to do an analysis of my customers and the distribution of them into categories. This is an example of my data:

example data

I want to know how many customers (cards) have tickets in A, B or C, and the amount spend on each of these categories, and then do the same thing but for each type of segment.

I want to do a bar chart with the percentage of tickets in each category of all my customers and then 3 charts of each segment.

Heres an example of what I want to get:

Example

The thing is that there are cards that have 0 tickets on that category. I've been thinking that it might work to add a column beside each category, adding for example an "if the row has tickets in category A", then put A in that row, so maybe its easier to create a column?

If you think that might work, how could I run that? Sorry but I'm very new on R and I have a huge data base :(

Thanks for your help!!

curls
  • 382
  • 1
  • 3
  • 16
maria
  • 1
  • 1
  • please explain what you have tried and/or any errors you are getting – Chris Oct 11 '15 at 02:07
  • Welcome to SO! Please see [how to make a great reproducible question](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – hrbrmstr Oct 11 '15 at 02:25
  • The `tapply` function would seem to be useful. You need to be more specific about how you want the subtotals presented. Are we supposed to `sum(`? Or are we supposed to intuit that you wanted the 'SalesA' to be associated with 'TickA'? – IRTFM Oct 11 '15 at 03:10
  • 1
    Thank you all, I've post an image of the results I want to get, hope that explains better. – maria Oct 12 '15 at 03:45

0 Answers0