[R] prevent line breaks with sink()

Greg Snow Greg.Snow at imail.org
Thu Dec 9 19:10:04 CET 2010


You can set options(width= ) with a sufficiently large number and you should not see the wrapping.  If you don't want wrapping or the initial [1], then consider using cat instead of print (or implied print), cat can even bypass the need for sink if you just want to send vector contents to a file.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Duncan.Ramsey at stdavids.com
> Sent: Thursday, December 09, 2010 10:52 AM
> To: r-help at r-project.org
> Subject: [R] prevent line breaks with sink()
> 
> Hello.
> I have a script that writes vectors to a txt file using sink(). But
> depending on the console window's size, sometimes you will get output
> like:
> 
> [1]  38  84 272 287 305 348 411 413 425 426 427 457 513 517 569 583 784
> [18] 866 933 996
> 
> Instead of:
> [1]  38  84 272 287 305 348 411 413 425 426 427 457 513 517 569 583 784
> 866 933 996
> 
> Does anyone know how to stop these automatic line breaks? Simply
> resizing the window won't help due to the length of some of these
> vectors.
> 
> While we're at it, I'd love for the '[1]' at the beginning to not
> print, but that's a much milder problem.
> 
> I'd appreciate any help!
> -D
> 
> ______________________________________________
> 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