in R, can I stop print(cat(“”)) from returning NULL? and why does cat(“foo”) return foo>

If I enter


I get


I want to use cat() to print out the progress of an R script, but I don't understand why it is returning NULL at the end of all of my concatenated strings, and more importantly, how to get it to stop?


All your answers are in the documentation for ?cat. The portions that answer your specific question are:

fill: a logical or (positive) numeric controlling how the output is
      broken into successive lines.  If ‘FALSE’ (default), only
      newlines created explicitly by ‘"\n"’ are printed.
      Otherwise, the output is broken into lines with print width
      equal to the option ‘width’ if ‘fill’ is ‘TRUE’, or the value
      of ‘fill’ if this is numeric.  Non-positive ‘fill’ values
      are ignored, with a warning.

... and ...

 None (invisible ‘NULL’).

So you can't stop print(cat(...)) from returning NULL because that's what cat returns. And you need to explicitly add newlines like cat("foo\n").

Need Your Help

Trackback/Pingback libraries for Python/Ruby?

python ruby blogs

I'm considering writing my own blog but I have had some issues deciding for an appropriate software. From my survey so far I have concluded that the easiest, most feature-rich, free software is

How to mock System.DirectoryServices.SearchResult?

.net unit-testing active-directory mocking

If you have a method that needs to be tested that takes a list of SearchResults

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.