I have made a custom function which creates a couple of strings. I would like to have these strings displayed on two lines (the first above the other). This is my current code:
---
output:
bookdown::pdf_document2:
toc: false
---
```{r echo = FALSE}
b <- function(d){
x <- paste("foo")
y <- paste("bar")
paste(x, "\n", y)
}
```
`r b()`
`r paste("this", "\n", "does", "\n", "work")`
However, while foo bar
is shown, it is only inline, not on different lines.
I have also tried the following:
paste0(x, "\n", y)
cat(x, "\n", y)
paste(x, y, sep="\n")
paste0(x, y, sep="\n")
cat(x, y, sep="\n")
None of these work inside the function. cat() actually doesn't even show anything when inside the function. What am I missing/doing wrong?