I have recently become familiar with the rstatix package. Below is an example code using functions from this package.
library(tidyverse)
library(rstatix)
library(ggpubr)
set.seed(1111)
n=100
df = tibble(
  x1 = rnorm(n, 0, 1.1),
  x2 = rnorm(n, 0.2, .1),
  x3 = rnorm(n, -.2, .2),
  x4 = rnorm(n, 0, 2),
) %>% pivot_longer(x1:x4)
df
pwc = df %>%
  pairwise_t_test(value~name, paired = TRUE,
                  p.adjust.method = "bonferroni") %>%
  add_xy_position(x = "name") %>%
  mutate(name=group1,
         lab = paste(p, " - ", p.adj.signif))
res.test = df %>% anova_test(value~name)
df %>% ggplot(aes(name, value))+
  geom_boxplot(alpha=0.6)+
  stat_pvalue_manual(pwc, step.increase=0.05, label = "lab")+
  labs(title = get_test_label(res.test, detailed = TRUE),
       subtitle = get_pwc_label(pwc))
However, I noticed that functions like get_test_label or get_pwc_label do not return text, but commands to prepare the text.
For example, calling get_test_label(res.test, detailed = TRUE) gives this:
paste("Anova, ", italic("F"), "(3,396)", " = ", 
    "5.26, ", italic("p"), " = ", "0.001", 
    paste(", ", eta["g"]^2, " = ", 0.04), "")
In turn, calling get_pwc_label(pwc) will result in:
paste("pwc: ", bold(c(t_test = "T test")), "; p.adjust: ", 
    bold("Bonferroni"))
Now my question, basically two questions.
- What could be the reason these functions do not return text but commands?
 - How to make your own function that returns similar commands.