Search code examples
rtextformatting

Text Formatting \n included in output instead of line break


When using this code in RStudio (as an example):

print("Hello\n World")

I get Hello\n World as the output instead of a line break. Any ideas why?

Thank you!


Solution

  • Use cat()instead of print().

    > cat("Hello \n World")
    Hello 
     World
    

    To know more: https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/cat