I'm working with a large collection of R Markdown files that are collectively used to create a book (PDF output) using bookdown
. For long lines of code (that will show up in the book), I've been writing it out close to column 80, at which point I insert a hard line break, tab (4 spaces) over, and continue the code. This is what I think looks good in the text (for readers). However, I'm running into problems when this is (for example) part of a ggplot()
function. Here's a quick (meaningless) example:
testx <- seq(1:100)
testy <- rnorm(testx)
testdat <- as.data.frame(cbind(testx, testy))
g <- ggplot(testdat, aes(x = testx/100, y = testy))
g <- g geom_point() geom_line()
g <- g labs(title = "The Posterior Distribution",
caption = "The mode and 95% HPD intervals are the dot and horizontal line at
the bottom, respectively.",
x = expression(beta[1]~(slope)))
g
In this example, I need to break the caption()
argument across two lines because it is long, but I do NOT want it to break in the actual caption.
Is there a way to do this?
CodePudding user response:
If I understood correctly, you can use paste0.
caption = paste0("The mode and 95% HPD intervals are the dot",
" and horizontal line at the bottom, respectively.")