The simlified issue is as follows:
library(dplyr)
library(ggplot2)
data.frame(x=c(1,10,100,1000,10000), nms = c("A","B","C","D","E")) %>%
ggplot(aes(x=x, y=nms)) +
geom_bar(stat = "identity") +
geom_text(aes(label = x),
vjust = 0.5, hjust = -0.1, color = "gray")
As it is seen here the digits of the geom_text are not displayed for certain values. I manually set the limits for the x axis for instance by adding + scale_x_continuous(limits=c(0,11000)). But it seems not a good practice as the value of the upper limit is set randomly. Scaling up the upper limit by for example 10% max(x)*1.1 is not a solution asd well as 10% is a random number especially if it is expected that log trans can be added (or not added) to the x scale depending upon the specific values for different datasets used for the same visualisation and thus it does not take into account the width of the printed text label.
So my question is: what is the proper solution to add these geom_text geoms?

Instead of definig the limits manualy you could use the expand arg. The default is 5% on each side so
expand = expansion(mult = c(0.05, 0.1))should do the trick.We could make the text go "inward" with
hjust = "inward"Or we could turn off clip with
coord_cartesian(clip = 'off')It may be necessary to adjust plot margins.
Created on 2023-05-26 with reprex v2.0.2