这个怎么样:
# needed libraries
library(ggplot2)
# custom function to prepare a caption
caption_maker <- function(caption) {
# prepare the caption with additional info
caption <- base::substitute(
atop(y,
paste(
"In favor of null: ",
"log"["e"],
"(BF"["01"],
") = ",
bf
)),
env = base::list(
bf = 123,
y = caption
)
)
# return the message
return(caption)
}
# custom function to add labels to the plot
plot_maker <-
function(xlab = NULL,
ylab = NULL,
title = NULL,
caption = NULL) {
caption.text <- caption_maker(caption = caption)
plot <- ggplot(mtcars, aes(wt, mpg)) + geom_point() +
ggplot2::labs(
x = xlab,
y = ylab,
title = title,
caption = caption.text)
# return the plot
return(plot)
}
plot_maker(caption = NULL)
plot_maker(caption = "This is mtcars:")
plot_maker(xlab = "x Axis Title",
caption = substitute(paste(italic("Note"), ": This is mtcars dataset"))
)
我拿到了
atop
question