0

I am trying to prepare a bar plot with the following code below. This is a grouped bar chart of number of services performed by sex for each year. My goal is to have a barplot similar to this

Image I am trying to get

Below is the code I have tried and it produces the image below.

ggplot(data=dfhips, aes(x=year, y=Tot_Srvcs, fill=Rndrng_Prvdr_Gndr)) +
  geom_bar(stat="identity", position=position_dodge())+
  geom_text(aes(label=Tot_Srvcs), vjust=1.6, color="white",
            position = position_dodge(0.9), size=3.5)

This is the str for the 3 columns I am trying to plot

'data.frame':   34940 obs. of  3 variables:
 $ year             : chr  "2013" "2013" "2013" "2013" ...
 $ Tot_Srvcs        : int  14 17 30 11 13 16 102 15 30 30 ...
 $ Rndrng_Prvdr_Gndr: chr  "M" "M" "M" "M" ...

What I am getting

Please how can i have only one label appear for each bar/category?

stefan
  • 90,330
  • 6
  • 25
  • 51
  • Welcome to SO. Please make your post [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by providing your dataset and code within your post, not as images. You can provide a portion of your dataset by using `dput(head(dfhips,n=10))` and then copy-pasting the output starting with "structure" into your original question. – jrcalabrese Nov 09 '22 at 18:17

0 Answers0