7

When using the print function to print to the screen, I would like one line to appear on one line, and the next line to be on a second line.

with this line

print( 
    paste( 
        "hey I want this to be line one", "and this to be line two", "would be great if you could help"
    )
)

I want this to print

[1] "hey I want this to be line one

[2] and this to be line two would be great if you could help"

MatthewR
  • 2,660
  • 5
  • 26
  • 37

1 Answers1

19

I assume your sample output should actually be three lines instead of two... You should use cat instead of print, and add sep="\n" to the paste statement:

 cat(paste("hey I want this to be line one", 
           "and this to be line two", 
           "would be great if you could help" ,sep="\n"))

Output:

hey I want this to be line one
and this to be line two
would be great if you could help
beroe
  • 11,784
  • 5
  • 34
  • 79