I am new to using ggplot2 and i am having trouble plotting a graph. I have looked around on SO but the solutions I found did not work with my data. Here is an example of my DF
Count1 Count2 Color
3 4 Red
3 6 Green
5 2 Red
2 0 Blue
I would like to just plot this is as a bar graph. I would like the X axis to consist of the colors and I would like to plot both the Count1 and Count2 variables on the y axis. for example, the two bars used to show the green color will go up to the number 3 (for count1) and the number 6 (for count2). Similarly, the red bar will go up to 8 (for count1) and 6 (for count2) Does anyone know how to go about doing this? Thanks!
library(tidyverse); df %>% group_by(Color) %>% summarise_all(sum) %>% gather(var, val, -Color) %>% ggplot(aes(x = Color, y = val, fill = var)) + geom_col(position = 'dodge')summarise_alltries to apply its function (sumhere) to all non-grouping columns, which for the sample data is fine, but may not be for your real data if there are non-numeric columns. (Also usestrto make sure your numeric columns are actually stored as doubles or integers.)summarise_atlets you specify columns, or just usesummariseand explicitly specify what to do with each column you want.