Re: [R] R-Terminal

From: Martin Elff <elff_at_sowi.uni-mannheim.de>
Date: Wed, 05 Mar 2008 13:37:26 +0100

On Wednesday 05 March 2008 (12:56:17), Martin Kaffanke wrote:
> Thats really great, but now the sink() uses also this width. Is it
> possible to make sink using another width (i.e. 80 characters)?

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




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. Received on Wed 05 Mar 2008 - 12:40:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 05 Mar 2008 - 13:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive