I have a dataframe with several variables that I wish to label and then use in several ggplots. I have applied labels using the labeller package with the following code.
library(tidyverse)
library(labeller)
library(ggpubr)
example.df <- data.frame(
origin = sample(c("hum_1", "mou_1"), 100, replace = TRUE),
v1 = rnorm(100, 100, 5),
v2 = rnorm(100, 10,5),
v3 = rnorm (100, 25, 5))
example.df <- example.df %>% set_variable_labels(origin = "original sample", v1 = "effect of Rx", v2 = "response", v3 = "weight (kg)")
This gets the labels to show up in the dataframe. However, when I use ggqqplot from ggpubr to plot these variables I don't see the labels in the resultant plots.
vars <- dput(colnames(select_if(example.df, is.numeric)))
lapply(vars, function(item) {
ggqqplot(example.df, x=item, combine = FALSE, facet.by = "origin")+
ggtitle(item)
}
)
I would like to have original sample, effect of rx and weight (kg) show up instead of v1, v2 and v3. Any help is much appreciated. Thanks.






ggqqplotfunction but it's not too difficult to build your own function to do what you want. See here for examples: stackoverflow.com/a/50522928 & stackoverflow.com/a/50930640ggtitlein the function? I cannot figure out how to write this function. I tried seq_along but it only repeats the first element as the title for all 3 plots.