I am getting Error: stat_count() can only have an x or y aesthetic. when trying to plot using data from an excel sheet
library(readxl)
library(dplyr)
library(ggplot2)
dataset= read_excel("D:/Downloads/Covid19.xlsx")
dataset2= read_excel("D:/Downloads/Covid19.xlsx", sheet = "Sheet2")
dataset3= dataset[,c(4,5)]
ggplot(dataset2, aes(x=Region, y= male))+geom_bar()
My Data from excel file looks like this Dataset
Excel
You need to include stat='identity'
, which is basically telling ggplot2 you will provide the y-values for the barplot, rather than counting the aggregate number of rows for each x value, which is the default stat=count
ggplot(dataset2, aes(x=Region, y= male)) + geom_bar(stat='identity')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With