Reputation: 1970
When doing
write("Hello", file = "Test.txt")
and open up my file Test.txt
in a text editor, it contains two rows (where the second is empty). How can I suppress write()
from inserting the ending newline command?
Upvotes: 2
Views: 29
Reputation: 2614
write
is a wrapper for cat
. If we use cat
like this, we got same result:
cat("Hello",file="Test.txt",sep="\n")
If we use cat without sep argument, we have text without new line:
cat("Hello",file="Test.txt")
Another way for writing is using cat
+ sink
:
sink("Test.txt")
cat("Hello")
sink()
For suppress write()
I don't find way.
Upvotes: 1