0

Here is some R code that shows newlines in a string become \n.

> foo <- "foo
+ bar"
> foo
[1] "foo\nbar"
> print(foo)
[1] "foo\nbar"

How can I get the printed output to show the newlines? That is:

foo
bar
dfrankow
  • 20,191
  • 41
  • 152
  • 214

1 Answers1

1

You can use the cat function to print it the way you are asking.

cat(foo)

from ?cat() you should keep in mind:

No linefeeds are output unless explicitly requested by "\n" or if generated by filling (if argument fill is TRUE or numeric).

Adam Wheeler
  • 393
  • 1
  • 11