I have a dataframe generated from a weighted survey of a list of countries and their subgroups
| Sampling Weights | Country | Gender | Percentage | n |
|---|---|---|---|---|
| 400 | A | Male | 20 | 100 |
| 600 | A | Female | 80 | 70 |
| 300 | B | Male | 30 | 45 |
| 500 | B | Female | 70 | 70 |
| 100 | C | Male | 40 | 100 |
| 50 | C | Female | 60 | 70 |
Using ggplot, I want to create a bar chart that has the n values of the subgroup in the x axis ticks. The x axis would be the countries with the male/female subgroups plus sample size and the y axis would be the percentage.
It would be too tedious to rename each subgroup name and add the sample size in parentheses so I was wondering if there was a faster way to do so while also being able to wrap the text around.
So
Male (n = 100) Female (n = 70) Country A
Keep in mind some of these Country names are actually long in the real data set so the labels would get crowded.

