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
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).