formattable
                                
                                
                                
                                    formattable copied to clipboard
                            
                            
                            
                        RFC: ggplot2 support
Attaching formatting to values is a very neat approach. Any thoughts on making this compatible with ggplot? Example:
data.frame(x=formattable::percent(1:10) / 100, y = 1:10) %>% ggplot(aes(x=x, y=y)) + geom_point()
I would expect the formatting to show up on the axes.
I've considered this indeed but haven't come up with a way to do this even with basic plot. I'll try more.
Still not working for me... We can't rely on scale_x_continuous(labels = format), when the labels are computed the class is lost already. I think this has to be fixed at the ggplot2 side?
library(tidyverse)
my_format <- function(x) {
  print(x)
  format(x)
}
data.frame(x = formattable::percent((1:10) / 100), y = 1:10) %>%
  ggplot(aes(x = x, y = y)) %>% 
  + geom_point() %>% 
  + scale_x_continuous(labels = my_format)

#> [1]    NA 0.025 0.050 0.075 0.100
Created on 2020-06-12 by the reprex package (v0.3.0)
Yes, I guess the plot function has to use the format string as the label rather than numeric value, or otherwise I guess I can do nothing about it.
Upstream: https://github.com/tidyverse/ggplot2/pull/4065.