[R] help output paged in separate window

Jim Lemon bitwrit at ozemail.com.au
Mon May 26 14:17:33 CEST 2003


Ted Harding wrote:
> Hi folks,
>
> I use R in X windows on Linux.
>
> Normally, I use 'less' as pager, which is fine for scanning through
> 'help' (or '?') output in the R window itself; the help session is
> terminated by typing "q", as usual for 'less', and the R window then
> reverts to the R command line interface.
>
> Often, I would like to have the output from 'help' pop up in a separate
> window so that I can continue to work in the R window while reading the
> help. The "help" window could then be closed when interest in this
> particular help dwindles.
>
> What can I set $PAGER to, to achieve this? Or should it be done in a
> different way (e.g. using some option to 'help' or to 'file.show')?
>
> (I don't want to use 'help.start' because of the overhead of using
> an HTML browser)
>
Well, here is a little function derived from the help browser macro I 
wrote for NEdit that will fire up an xterm with less displaying the help 
for a function. I haven't accounted for operators, but it could be done, 
and I haven't extensively tested it, but I suppose I shouldn't expect to 
have all the fun...

Jim

helpless<-function(topic) {
 topic<-substitute(topic)
 sys.command<-paste("locate ",topic,sep="",collapse="")
 helpfilelist<-system(sys.command,TRUE)
 helpmatch<-paste("help/",topic,sep="",collapse="")
 # find the R text help file(s)
 helpfile<-helpfilelist[grep(helpmatch,helpfilelist)]
 # assume that the shortest name matching "topic" will be the one
 if(length(helpfile) > 1)
  helpfile<-helpfile[which.min(nchar(helpfile))]
 sys.command<-paste("xterm -e less ",helpfile,sep="",collapse="")
 system(sys.command)
}




More information about the R-help mailing list