Mark Heckmann
2010-Nov-26 16:32 UTC
[R] options()$width does not equal actual console width - why?
I am writing a function that breaks the output if it gets bigger than the available console width. I noticed that a right margin always remains. The following code shows that the actual console size is always bigger than the one reported by options()$width. What might be the reason? (Software: MacOS 10.6, R 2.12)> cat(paste(rep(c(1:9, 0), each=10), collapse=""))11111111112222222222333333333344444444445555 55555566666666667777777777888888888899999999 990000000000> options()$width[1] 46> cat(paste(rep(c(1:9, 0), each=10), collapse=""))11111111112222222222333333333344444444445555555555666666666677777 77777888888888899999999990000000000> options()$width[1] 59 Thanks Mark ??????????????????????????????????????? Mark Heckmann Blog: www.markheckmann.de R-Blog: http://ryouready.wordpress.com
Petr Savicky
2010-Nov-26 18:05 UTC
[R] options()$width does not equal actual console width - why?
On Fri, Nov 26, 2010 at 05:32:54PM +0100, Mark Heckmann wrote:> I am writing a function that breaks the output if it gets bigger than the available console width. > I noticed that a right margin always remains. The following code shows that the actual console size > is always bigger than the one reported by options()$width. What might be the reason? > (Software: MacOS 10.6, R 2.12) > > > cat(paste(rep(c(1:9, 0), each=10), collapse="")) > 11111111112222222222333333333344444444445555 > 55555566666666667777777777888888888899999999 > 990000000000 > > options()$width > [1] 46 > > > cat(paste(rep(c(1:9, 0), each=10), collapse="")) > 11111111112222222222333333333344444444445555555555666666666677777 > 77777888888888899999999990000000000 > > options()$width > [1] 59I am not sure, whether the actual console size is always bigger. The command options(width=n) may set the width to any n between 10 and 10000 independently on the actual console size. The help page ?options says Some R consoles automatically change the value when they are resized. In order to get the actual console size under Linux, one can use Sys.getenv("COLUMNS"). I do not know, whether this applies also to MasOS. Petr Savicky.