Bug 16758 - the 'fill' argument to function 'cat' does not function as one would expect based on documentation
Summary: the 'fill' argument to function 'cat' does not function as one would expect b...
Alias: None
Product: R
Classification: Unclassified
Component: Documentation (show other bugs)
Version: R 3.2.1
Hardware: Other Linux
: P5 normal
Assignee: R-core
Depends on:
Reported: 2016-03-10 21:23 UTC by dgrove.wa
Modified: 2016-03-11 17:57 UTC (History)
0 users

See Also:

example R code to illustrate (1.18 KB, text/x-r-source)
2016-03-11 17:57 UTC, dgrove.wa
example code output (2.68 KB, text/plain)
2016-03-11 17:57 UTC, dgrove.wa

Note You need to log in before you can comment on or make changes to this bug.
Description dgrove.wa 2016-03-10 21:23:03 UTC
I'm not sure if the problem is in the documentation or in the function implementation.  

Based on my reading of the documentation for cat(), I expected that using e.g.
the code cat(a, b, c, fill=70) would concatenate strings a, b and c, and
then split the resulting string into sub-strings of length <= 70 characters
and print one per line.  Presumably the splitting would be done at word-boundaries, though this is not stated.

However, the actual behavior of cat(a, b, c, fill=70) is to only split 
printed lines *between* the objects 'a', 'b', and 'c'.  If each of the
strings 'a', 'b' and 'c' is longer than 70 characters, then the output
will have each of the strings on their own line and each line will (obviously)
be longer than 70 characters.  If concatenation of some of the elements is
results in a string with fewer than 70 characters, this will be done and
they will appear on a single line.  But no splitting of long strings will

So this behavior of cat() with 'fill' specified (as TRUE or positive integer) 
is really only useful if you're passing it a bunch of short strings. 

Perhaps this is obvious to whomever wrote the documentation, but it's not at all obvious to me when I read it.  

Comment 1 dgrove.wa 2016-03-11 17:57:15 UTC
Created attachment 2041 [details]
example R code to illustrate
Comment 2 dgrove.wa 2016-03-11 17:57:57 UTC
Created attachment 2042 [details]
example code output