Skip to content

R-Terminal

8 messages · Martin Kaffanke, Gábor Csárdi, Peter Dalgaard +1 more

#
Hi there!

I use an gnome-terminal for using R.  When I resize the termial to the
maximum size, R uses only the left side of the window.  Can I tell R to
use the whole window somehow?

Thanks,
Martin
#
options(width=120)

See ?options

G.
On Tue, Mar 04, 2008 at 12:04:54PM +0100, Martin Kaffanke wrote:
[...]
#
Martin Kaffanke wrote:
This seems to do it:

options(width=Sys.getenv("COLUMNS"))        

(Surprisingly, at least to me, the COLUMNS environment variable appears
to be automagically updated by gnome-terminal even after R is started. I
was expecting to have to play with system("tset") and suchlike.)
#
Am Dienstag, den 04.03.2008, 12:34 +0100 schrieb Peter Dalgaard:
Thats great!  Is there something like an rc file where I can generally
save this?

lg,
Martin
#
On Tuesday 04 March 2008 (12:34:47), Peter Dalgaard wrote:
That seems to work also with KDE's "Konsole". 

It may be worthwile considering
to implement some automatic width-adjustment like:

.adjustwidth <- function(...){
	options(width=Sys.getenv("COLUMNS"))
	TRUE
}

addTaskCallback(.adjustwidth)

After that, the output width is adapted to the actual terminal width
each time one hits return.


Just my 20 cents.
Best,
Martin
#
On Tue, Mar 04, 2008 at 01:18:43PM +0100, Martin Kaffanke wrote:
See ?Startup

G.

        

  
    
#
Thats really great, but now the sink() uses also this width.  Is it
possible to make sink using another width (i.e. 80 characters)?

Thanks,
Martin


Am Dienstag, den 04.03.2008, 13:23 +0100 schrieb Martin Elff:
#
On Wednesday 05 March 2008 (12:56:17), Martin Kaffanke wrote:
# auto width adjustment

.adjustWidth <- function(...){
 ??????options(width=Sys.getenv("COLUMNS"))
 ??????TRUE
}
 
.adjustWidthCallBack <- addTaskCallback(.adjustWidth)

# a wrapper for 'sink'

Sink <- function(...,width=80){
 if(nargs()){
	 removeTaskCallback(.adjustWidthCallBack)
	 rm(.adjustWidthCallBack,envir=globalenv())
         options(width=width)
	 sink(...)
	}
 else{
    sink()
    assign(".adjustWidthCallBack",
	addTaskCallback(.adjustWidth),
	envir=globalenv()
	)
 }
}

# test
Sink("test.out",width=20) # nonsensically narrow, but shows that
                          # width=<something> has an effect...
iris[1:10,]
Sink()
as.matrix(readLines("test.out"))
iris[1:10,]


Best,
Martin


-------------------------------------------------
Dr. Martin Elff
Faculty of Social Sciences
LSPWIVS (van Deth)
University of Mannheim
A5, 6
68131 Mannheim
Germany

Phone: +49-621-181-2093
Fax: +49-621-181-2099
E-Mail: elff at sowi.uni-mannheim.de
Web: http://webrum.uni-mannheim.de/sowi/elff/
     http://www.sowi.uni-mannheim.de/lspwivs/
-------------------------------------------------