Printing newlines with print() in R
I am trying to print a multiline message in R. For example,
print("File not supplied.nUsage: ./program F=filename",quote=0)
I get the output
File not supplied.nUsage: ./program F=filename
instead of the desired
File not supplied.
Usage: ./program F=filename
The r print newline function shows you a version of the object from the R level - in this case, it is a character string. You need to use other functions like cat() and writeLines() to display the string.
writelines()
> writeLines("File not supplied.
Usage: ./program F=filename")
File not supplied.
Usage: ./program F=filename
>
In the writelines() function, you do not need to append a "
" to the string passed to get a newline after your message.
cat()
> cat("File not supplied.
Usage: ./program F=filename")
File not supplied.
Usage: ./program F=filename
> cat("File not supplied.
Usage: ./program F=filename","
")
File not supplied.
Usage: ./program F=filename
>