How to generate grouped stacked barplot with ggplot?

by Dieunel Derilus   Last Updated October 20, 2019 05:26 AM

I am trying to generate a grouped stacked barplot in ggplot. My grouped variable is "person" . Here is my script :

v1
   person variable value cat
1       A   value1   100  a1
2       A   value1   150  a2
3       B   value1   120  a3
4       B   value1    80  a4
5       B   value1   150  a5
6       A   value2    25  a1
7       A   value2    30  a2
8       B   value2    45  a3
9       B   value2    30  a4
10      B   value2    30  a5

ggplot(v1, aes(x = cat, y = value, fill = variable)) + 
+   geom_bar(stat = 'identity', position = 'stack') + facet_grid(~ person)```

[here is the the resulted plot][1]
Why  i have the extra samples  samples ID(cat) in my group ?  How  can remove them ?

Thanks in advance!
DD


  [1]: https://i.stack.imgur.com/QzMtU.png
Tags : r ggplot2


Related Questions


Updated May 28, 2015 23:11 PM

Updated May 29, 2015 01:11 AM

Updated April 03, 2015 23:11 PM

Updated April 10, 2015 23:11 PM

Updated October 09, 2016 09:11 AM