From ccberry at ucsd.edu  Fri Mar 16 18:13:43 2018
From: ccberry at ucsd.edu (Berry, Charles)
Date: Fri, 16 Mar 2018 17:13:43 +0000
Subject: [Rd] cat(fill=N)
In-Reply-To: <d18f4888-7279-580c-ec50-f59b49c59418@insa-toulouse.fr>
References: <CAARY7ki-sZKdhFaknTh5pDOWTLumw==RiVs0Wi2BDGkOSLUuhA@mail.gmail.com>
 <d18f4888-7279-580c-ec50-f59b49c59418@insa-toulouse.fr>
Message-ID: <5667085D-732F-4BEB-8FB7-1A2A21CA4022@ucsd.edu>



> On Mar 16, 2018, at 9:19 AM, Serguei Sokol <sokol at insa-toulouse.fr> wrote:
> 
> Le 16/03/2018 ? 17:10, David Hugh-Jones a ?crit :
>> Hi all,
>> 
>> I expect I'm getting something wrong, but
>> 
>> cat("foo bar baz foo bar baz foo bar baz", fill = 10)
>> 
>> should be broken into lines of width 10, whereas I get:
>> 
>>> cat("foo bar baz foo bar baz foo bar baz", fill = 10)
>> foo bar baz foo bar baz foo bar baz
> On the other side, if I do
> > cat(strsplit("foo bar baz foo bar baz foo bar baz", " ")[[1]], fill = 10)
> I get the expected result:
> 
> foo bar
> baz foo
> bar baz
> foo bar
> baz
> 
> Which suggest that cat() doesn't break elements of submitted character vector
> put put enough of them to fill the requested width.

Also, see ?strwrap, which honors word boundaries

> cat(strwrap("foo bar baz foo bar baz foo bar baz", width = 10),fill=10)
foo bar 
baz foo 
bar baz 
foo bar 
baz
> 

HTH,

Chuck


[Rd] cat(fill=N)
Berry, Charles