I would like to pass the label_format
expression to ggplot but I'm getting an error
#toy df
df <- data.frame(
x = 1:10,
y = seq(0.1,1,by=0.1),
label_format = "scales::percent_format(accuracy=0.1)"
)
ggplot(df,aes(x=x,y=y))+
geom_point()+
scale_y_continuous(label=!! rlang::parse_expr( label_format))
Error in parse_exprs(x) : object 'label_format' not found
I would like to evaluate the string to end up with this plot with formatted y-axis:
ggplot(df,aes(x=x,y=y))+
geom_point()+
scale_y_continuous(label=scales::percent_format(accuracy = 0.1))