replace_plot_labels | R Documentation |
If the data stored in a ggplot object has variable labels then this will replace the variable names with the variable labels. If no labels are set then the variable names will be tidied and a nicer version used.
replace_plot_labels(plot)
plot |
output from a call to ggplot2 |
set_var_labels()
for setting individual variable labels,
set_labels()
for setting variable labels using a data frame,
extract_labels()
for creating a data frame of all variable labels,
clear_labels()
for removing variable labels
## Not run:
data("pembrolizumab")
p <- ggplot(pembrolizumab,aes(x=change_ctdna_group,y=baseline_ctdna)) +
geom_boxplot()
replace_plot_labels(p)
pembrolizumab <- set_var_labels(pembrolizumab,
change_ctdna_group="Change in ctDNA group")
p <- ggplot(pembrolizumab,aes(x=change_ctdna_group,y=baseline_ctdna)) +
geom_boxplot()
replace_plot_labels(p)
# Can also be used with a pipe, but expression needs to be wrapped in a brace
(ggplot(pembrolizumab,aes(x=change_ctdna_group,y=baseline_ctdna)) +
geom_boxplot()) |> replace_plot_labels()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.