I am producing a facet chart like this
suppressPackageStartupMessages({
library(tidyverse)
library(scales)
})
set.seed(123456)
test_df <-
tibble(t=1:10,
x=100+runif(10,-10,10),
y=10+runif(10,-4,4),
p=y/x)
test_df |>
pivot_longer(cols=x:p,
names_to = "var",
values_to = "value") |>
mutate(var=factor(var,levels=c("x","y","p"))) ->
test_df_long
test_df_long |>
ggplot(aes(x=t,y=value)) +
geom_line() +
scale_y_continuous(limits=c(0,NA)) +
facet_wrap(vars(var),ncol=1,
scales = "free_y")
I would like to change the formatting of the labels for the p facet to percent.
I have not found a way to use different labelling functions to different facets.
Can it be done?