I want to make a grouped bar chart where each month is clustered together, then within that cluster each variable gets its own bar. So for the sample code below (my actual data has more than 2 rows) I want a bar for x1, for x2, for x3 and for x4 in January, then again a bar for x1, for x2, for x3 and for x4 in February, etc.
x1 | x2 | x3 | x4 | Month |
---|---|---|---|---|
7.8 | 3.4 | 9.8 | 2.1 | Jan |
5.5 | 2.3 | 6.1 | 0.7 | Jan |
I must be missing something fairly obvious but I can't figure out how to make each column a bar. This is my best guess so far,
Levels = c(x1, x2, x3, x4)
Plot <- ggplot(data, aes(x = Month, fill = Levels)) + geom_col(position = 'dodge')
which is obviously wrong because Levels isn't connected to the data in any way.
Any ideas would be appreciated.