Search code examples
rconsole

unwanted indentation in console output


In rstudio when I run this code:
cat(strrep("-", 5), "\n", strrep("-", 5))
The dashed line in the second row indented. How do I remove the indent?

I want this:
-----
-----

I get this:
-----
-----


Solution

  • the "indent" comes from a space that separates the entries of cat() so just add sep="" to the argument of cat(...)

    cat(strrep("-", 5), "\n", strrep("-", 5),sep="")