1

Here is my example

    mydf = data.frame('col_1' = c('A','A','A', 'B','B'),
 'col_2' = c('positive', 'negative', 'negative', 'positive', 'positive'))
    mydf
    ggplot(data=mydf, aes(x = col_1, fill = col_2))+ geom_bar(stat='count')

Here is what it produces: bar plot

I would like bar to add up to 100%. So first bar will show split 33% and 67% and second bar will be 100 %

I know how to manipulate data, but I don't know how to cast it into format necessary for ggplot.

Any suggestions?

user1700890
  • 7,144
  • 18
  • 87
  • 183
  • 2
    See `position_fill()` – Henrik May 18 '17 at 15:15
  • @Henrik Thank you so much, I searched web for 30 minutes and could not find it. – user1700890 May 18 '17 at 15:23
  • 1
    No, sometimes you just don't hit the right terms ;). I found a relevant post which has a `ggplot` answer pointing to `fill`, and close your question. I will see if I can edit that post and title to make it somewhat more searchable. – Henrik May 18 '17 at 15:26
  • 1
    Edited the linked post. Hopefully it will now be easier to find for future searches. – Henrik May 18 '17 at 15:47

0 Answers0