79346218

Date: 2025-01-10 15:43:37
Score: 1
Natty:
Report link

UPDATE

comma() is now superseded by label_number().

The syntax is a bit different. There is no x argument as before. The label_ creates a function then the after_stat is feeded to it.

Using the exemple by @stefan it would be:

library(ggplot2)

ggplot(mpg, aes(x = class)) +
geom_bar(fill = '#00798c')  +
geom_text(stat = "count", 
          aes(label = scales::label_number(scale = 1000, big.mark = ",")(after_stat(count))), 
          position = position_dodge(width = 0.8), 
          vjust = -.3, fontface = "bold")
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @stefan
  • Low reputation (1):
Posted by: Marc-Antoine L