Skip to content

prevent line breaks with sink()

2 messages · Duncan.Ramsey at stdavids.com, Greg Snow

#
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
#
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.