title: Split barplot using position = "fill" into separate facets
body: <p>I created a bar graph in ggplot using stat = &quot;count&quot; and position = &quot;fill&quot; to show the proportional occurrence of each feature per year (below). I find the readability of this graph rather poor and therefore I'd like to split the graph into facets. However, if I add facet_wrap(~Features), it just fills the bars in every separate facet. How can I prevent this from happening?</p>
  <p>The code for my original graph is:</p>
  <pre><code>data %&gt;% ggplot(aes(x = Year, fill = Features)) + geom_bar(stat = &quot;count&quot;, position = &quot;fill&quot;) + theme_classic() + theme(axis.text.x = element_text(angle = 90)) + scale_y_continuous(labels = scales::percent)
  </code></pre>
  <p>I've tried:</p>
  <pre><code>data %&gt;% ggplot(aes(x = Year)) + stat_count(geom = &quot;bar&quot;, aes(y = ..prop..)) + facet_wrap(~Features) + theme_classic() + theme(axis.text.x = element_text(angle = 90))
  </code></pre>
  <p>but this calculates the proportion within the facet rather than within each year.</p>
  <p>Any ideas how I can solve this (using ggplot, rather than by restructuring my data)?</p>
  <p><a href="https://i.stack.imgur.com/L6VTJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L6VTJ.png" alt="enter image description here" /></a></p>
  <p>A little about my data:</p>
  <p>I have a data frame of features (factor) with for each feature the year (factor) in which this feature was observed. The same feature can occur several times per year, so there are several rows with the same entry for year and feature.</p>