[R] formatting print statements with multiple lines

Stephan Kolassa Stephan.Kolassa at gmx.de
Thu Dec 18 22:30:54 CET 2008


Use cat() with "\n" for newlines and "\t" for tabs,

cat("Input criteria does not meet specifications.  Check input against 
the following requirements:\n\ta >= 0\n\t")

HTH,
Stephan


Brigid Mooney schrieb:
> When executing the command:
> 
>     print(cat(paste("Input criteria does not meet specifications.  Check
> input against the following requirements:
>             a >= 0
>             b <= 0
>             c >= 0 ", sep=""), ""))
> 
> I get:
> Input criteria does not meet specifications.  Check input against the
> following requirements:
>             a >= 0
>             b <= 0
>             c >= 0  NULL
> (with that extra NULL at the end).
> 
> If I omit the 'cat' command, the NULL goes away, but I no longer get the
> next-line formatting that I want.
> 
> I think I'm missing something about one of these functions returning a NULL
> value, but I can't seem to get the exact result I want (no NULL value, and
> keep the next-line formatting.)
> 
> Any ideas or suggestions are much appreciated.
> 
> Thanks!
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list