0

if I knit my RMarkdown I get a result with the following problem:

enter image description here

My codeline runs out of the codeblock. How can I avoid it? Is there an option to get a "linebreak" or something else?

Thank you for your help.

Christian01
  • 307
  • 1
  • 5
  • 19
  • 2
    Does https://stackoverflow.com/q/33481271/3358272 resolve the issue? – r2evans Dec 17 '22 at 16:12
  • 4
    I have written entire packages where no line of code is over 80 characters long, and almost never post SO answers where any line of code is greater than 80 characters. It is always possible to write code so that it fits nicely in a code block, and if you are publishing a code block in a markdown document, why wouldn't you simply adjust your code to make it readable? – Allan Cameron Dec 17 '22 at 16:19
  • I am not sure if this helps but in Rstudio under `Code` tab we can activate `Soft Wrap Long Lines` – TarJae Dec 17 '22 at 17:52

1 Answers1

0

You can construct a very long string using paste0(). For example,

x <- "this string isn't very long, but I'd still like it to be shorter."
y <- paste0("this string isn't very long, ",
            "but I'd still like it to be shorter.")
identical(x, y)
#> [1] TRUE

Created on 2022-12-17 with reprex v2.0.2

user2554330
  • 37,248
  • 4
  • 43
  • 90