replace_plot_labels {reportRmd} | R Documentation |
Replace variable names with labels in ggplot
Description
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.
Usage
replace_plot_labels(plot)
Arguments
plot |
output from a call to ggplot2 |
See Also
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
Examples
## 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)
[Package reportRmd version 0.1.1 Index]