'R - Grouped Barplot with legend

I have tried to replicate code/ guidance from other answers to grouped barplot help but always seem to encounter error messages. I get these even before trying to add in titles/ legend.

I have the below dataset;

Month CT Report Terminals ATM DB Terminals Member Stats Terminals HC Errors
Nov-21 406 139 1251 888
Dec-21 640 1438 1544 740
Jan-22 795 939 1000 297

I want to replicate the below graph;

enter image description here

I can do this easily in excel but trying to stick with R. I have the below code;

library(ggplot2)

read_excel("ct_summary.xlsx")

data <- read_excel("ct_summary.xlsx")

Category <- c("CT Report Terminals", "ATM DB Terminals", 
              "Member Stats Terminals", "HC Errors")

ggplot(data, aes(x = Category, y = Category, fill=Month)) +
  geom_bar(stat="identity", position = "dodge")

The error message Error: Aesthetics must be either length 1 or the same as the data (3): x and fill keeps appearing or I get errors around bar height.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source