I'm trying to vary the size of a geom_text() layer in a ggplot so that the labels are always narrower than a given range. The ranges are defined in the data, but what I don't know is how to scale the label to be narrower than that, without a ton of trial and error.
What I hope is that I can construct a function of label size and nchar(label) (realizing character width varies a bit) that would return a width that I could compare to the shape width, and scale down until no longer necessary.
Are the ggplot label sizes defined as a number of pixels, percentage of the plot height, or something else like that?

nchar(label)you may want to usestrwidth(label). I only foundstrwidth()as I finished my last project on which it would have been very useful. - Gregor Thomas