title: Plotting non-numerical categorical data in ggplot2
body: <p>I am looking for ideas on how to plot a data set of 100 samples in ggplot structured as follows:</p>
  <pre><code>df &lt;- data.frame(sample = c(1:5), 
                   group = c(&quot;class 1&quot;, &quot;class 1&quot;, &quot;class 3&quot;, &quot;class 3&quot;, &quot;class 3&quot;),
                   cat_1 = c(&quot;D&quot;, &quot;Mj&quot;, &quot;Mj&quot;, &quot;Tr&quot;, &quot;Mn&quot;),
                   cat_2 = c(&quot;D&quot;, &quot;-&quot;, &quot;Mn&quot;, &quot;Tr&quot;, &quot;Mj&quot;),
                   cat_3 = c(&quot;Mn&quot;, &quot;Tr&quot;, &quot;D&quot;, &quot;Tr&quot;, &quot;Mn&quot;),
                   cat_4 = c(&quot;-&quot;, &quot;-&quot;, &quot;Mj&quot;, &quot;-&quot;, &quot;Mn&quot;))
  </code></pre>
  <p>The number of samples per group varies.
  I have 20 different categories (i.e. cat_1 ... cat_20) and 6 groups in my actual data.</p>
  <p>D is greater than 50% of a particular category.
  Mj is between 5% and 50%.
  Mn is between 1% and 5%,
  Tr is less than 1%.
  Not observed in the sample is denoted &quot;-&quot;.</p>
  <p><a href="https://stackoverflow.com/questions/34984132/plot-non-numeric-data">Plot non-numeric data</a> provides some ideas. Essentially I want to show the breakdown of categories by group. I am seeking inspired plots for a scientific report. I was thinking of a doughnut plot for each group with the number of samples in each group in the middle of the doughnut. However, this is hard to interpret at one level. I need to honour the data.</p>
  <p>This is the best I can do so far:</p>
  <pre><code>df %&gt;% 
    pivot_longer(c(3:6), names_to = &quot;category&quot;) %&gt;%
    group_by(group, category) %&gt;%
    mutate(count = n(),
           value = ifelse(value == &quot;-&quot;, NA, value)) %&gt;%
    ungroup() %&gt;%
    drop_na() %&gt;%
    ggplot(aes(value, fill = category)) +
    geom_bar() +
    xlab(&quot;abundance&quot;) +
    facet_wrap(~ group)`
  </code></pre>