You have to manually choose the number of characters to wrap at, but the combination of strwrap
and paste
will do what you want.
wrapper <- function(x, ...)
{
paste(strwrap(x, ...), collapse = "
")
}
my_title <- "This is a really long title of a plot that I want to nicely wrap and fit onto the plot without having to manually add the backslash n, but at the moment it does not"
r +
geom_smooth() +
ggtitle(wrapper(my_title, width = 20))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…