Barplot with two variables

Hi, May I ask for some advice concerning side-by-side barplots for factor variables?

My data looks like this, with upp to 2000 rows. One row equals one catched rodent.

rodID year area class
1 S1 2014 S mouse
2 S2 2014 G mouse
3 S3 2015 S vole
4 S4 2015 G vole
5 S5 2016 S mouse
6 S6 2016 G vole

I have two questions:

When I use:

ggplot(firedata, aes(x=year, fill=class))+ geom_bar()

I get a nice barplot of the tree classes in one bar per years.

But I would like two bars per year, comparing the two areas. How do I do that?

The second question is that I want to adjust for effort (the amount of traps used in each area per year, which means that I have different number of traps used for each year that I want to correct for: counts of rodents caught with x traps). Is it possible to do that directly with this data or is it necessary to create a new data frameā€¦?
Thankful for help!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.