I noticed that there is an API change for labeling in the
scales package, but I'm not clear on what the change should be to. For instance, using percentage formats has been the following:
library(scales) library(ggplot2) mydf <- tibble::tibble(perc = seq(0, 0.2, by = 0.05), cats = LETTERS[1:5]) ggplot(mydf, aes(x = cats, y = perc, label = percent(perc))) + geom_text()
But the help page for
percent() has the following note:
percent_format()are retired; please use
But how do I change the code above? The following leads to an error, and it's not clear from the set of examples in the help page how it should be used within
ggplot(mydf, aes(x = cats, y = perc, label = label_percent(perc))) + geom_text() #> Don't know how to automatically pick scale for object of type function. Defaulting to continuous. #> Error: Aesthetics must be valid data columns. Problematic aesthetic(s): label = label_percent(perc). #> Did you mistype the name of a data column or forget to add stat()?