Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 212041

Creating multi-category stacked bar charts in R

$
0
0

I'm trying to create some figures to display relative abundances of different trophic groups across 7 sites.

The data that I have is set up as:

                Species,          Trophic Group,    Specific Trophic Group,    Mean Abundance, Site ID
Example 1:   *P.coelestis*        Omnivore          Generalist Omnivore         38               1
Example 2:   *A. clarkii*         Planktivore       Omnivorous Planktivore       2.33            1

I have this for each site, e.g. for site 1 I have 5 Trophic Groups, and 7 more specific trophic groups.

What I was hoping to do is generate a bar chart where I have a cluster of bars for each site. Within each site, I could then have a bar for each main trophic group e.g. Herbivore, Omnivore, Planktivore, Predator etc. and then each bar could be split into relative abundances of the specific trophic groups so e.g. the herbivore bar could be divided into grazers, browsers and scrapers.

Does anyone have any tips on how to do this?

My alternative idea was to try and generate a donut chart for each site... I managed to use ggplots 2 to create a donut chart for both the main trophic group and the specific trophic group... but I am struggling to overlay the two together... I tried to use the floating.pie function but I'm not having any luck with that.

Any tips would be much appreciated!

Thank you!


Viewing all articles
Browse latest Browse all 212041

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>