SOLVED: Re: [R] help output paged in separate window

Roger Bivand Roger.Bivand at
Tue May 27 11:59:14 CEST 2003

On Tue, 27 May 2003 Ted.Harding at wrote:

> May I thank everyone who chipped in with suggestions and comments about
> this question.
> On one contribution: Robert Espresso suggested how to amend Jim Lemon's
> function 'helpless' so as to put it in the background.
> This works (as far as putting it in the background is concerned).
> However, by experiment I found that Jim's function is limited because
> of the way it looks for what to feed to 'less' and it sometimes succeeds
> but in general will not succeed and so 'less' will get empty input.
> E.g., with Robert's mod of Jim's function, compare the results of
> "?library" (which works) with "?RNGkind" (which doesn't).
> However, after a little reflection (which I could have done earlier ... )
> I've found a very straightforward solution for Unix systems, outlined
> below, which allows anything which would have been sent to R's pager to be
> shown on a separate and fully-detached window using 'less'. The details
> shown have been implemented in Linux, but the principles are applicable
> on all Unix and the method should work either exactly as it is or with
> minor modifcations.
> 1. Create a file in your $PATH with name "pgr" containg the lines
>   #! /bin/bash
>   export HLPFIL=`mktemp R_hlp.tmp.XXXXXX`
>   cat > $HLPFIL
>   xterm -e less $HLPFIL &
> and make it executable ("chmod 755 pgr"). (You may want to change the
> first line, depending on your shell, or you may well be able to omit it
> altogether). The 'mktemp' function generates a filename which is unique
> within its directory.
> 2. Give R the command
>   options(page="pgr")
> where "pgr" can be replaced by a full pathname if required.
> That's it: Now try "?library", ""random")", "help(RNGkind)"
> or anything else!
> If you use this a lot, you will find it handy to have a method of
> automatically deleting all the "R_hlp.tmp.XXXXXX" files you've created
> in a session.

Or even use R to generate the shell script in a directory from tempdir():

.xthelp <- function() {
    tdir <- tempdir()
    pgr <- paste(tdir, "/pgr", sep="")
    con <- file(pgr, "w")
    cat("#! /bin/bash\n", file=con)
    cat("export HLPFIL=`mktemp ", tdir, "/R_hlp.XXXXXX`\n", sep="", file=con)
    cat("cat > $HLPFIL\nxterm -e less $HLPFIL &\n", file=con)
    system(paste("chmod 755 ", pgr, sep=""))

source() this; then the files go away when R quits. This still leaves the
function object in the global environment. The mode can also be 750 or
tighter since execute permissions for other users seem a bit unnecessary?


> Best wishes to all,
> Ted.
> ______________________________________________
> R-help at mailing list

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at

More information about the R-help mailing list