I have created a graph from two variables (customer.complaints and Date_by_month) for the trend chart of monthly granularity levels but on the y-axis, it's showing me the name of the complaints, instead of that I want the total number of complaints in that particular month.
This is the graph I am getting
as you can see the value of the y-axis it quite annoying. instead of that, I want to add the count of the values
Here is my code snippet
library(ggplot2)
library(scales)
### Provide the trend chart for the number of complaints at monthly and daily granularity levels.
# converting date var to date type
comcast$Date <- gsub('-', '/', comcast$Date)
comcast$Date <- as.Date(comcast$Date, '%d/%m/%Y')
# plotting graph for monthly granularity levels
comcast$Date_by_month <- as.Date(cut(comcast$Date, breaks='month'))
ggplot(comcast, aes(Date_by_month, Customer.Complaint)) + stat_summary(fun.y=sum, geom='bar') + scale_x_date(labels=date_format("%Y-%m"), breaks='1 month') + scale_y_continuous(labels = fun.y= length)