Hi all
I am making a Shiny app. I tried to make a histogram with the count visualised per bin.
This is the output:
This is the code for the ggplot histogram:
ggplot(data = df_TAT_filtered,
mapping = aes(TAT)) +
geom_histogram( binwidth = 5, boundary = 0, color="blue", fill="light blue") +
stat_bin(binwidth = 5, center = 2.5, geom="text", aes(label=..count..), vjust = -1) +
xlim(0, input$upper_limit) +
labs(title="amount of samples and their TAT",x="TAT (in classes of 5 mins)", y = "amount of samples") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(axis.text.x = element_text(angle = 90)) +
scale_x_continuous(limits = c(0, input$upper_limit), breaks = seq(0, input$upper_limit, 5))
I want to remove the 0 count labels. I tried to adapt like this:
stat_bin(binwidth = 5, center = 2.5, geom="text", aes(label= if_else(..count.. > 0), ..count.., ""), vjust = -1)
I get this error (even when I add "stat = count", the problem remains):
How can I solve this?
Thanks in advance!