I'm trying to create a barplot but confused...I'm very new to R
Here is how the dataframe looks like
I want to create a barplot to show age distribution but based on the exposed column, the exposed column have 2 groups, one is call the control group as you can see in the picture, the other one is called the test group.
so far I only know how to create a barplot based on one column.
barplot(table(df$income), ylab="amount of income blocks",main="Barplot of Income",col = "firebrick", las=2)
As requested, this is the screenshot of what dput(df$exposed) looks like
and this is what dput(df$age) looks like
what I want the barplot to look like is to have 2 barplots, the first barplot shows the age distribution based on the number of test group, the second barplot shows the age distribution based on the number of control group.
Or, if you can, it would be better to show just 1 barplot with different color that 1 color represent test group and 1 color represent control group with all the age distribution.