Skip to content

Is it possible to open a specific file in the HTML browser like help(htmlhelp=TRUE) does?

4 messages · Henrik Bengtsson, Brian Ripley, Zed Shaw +1 more

#
Dear all/anyone, after generating a HTML file "result.html" from within [R],
I would like to open the default HTML browser (like help.start() does) to
show the file. Is it possible to do this (without trying to do a system
dependent search for possible browsers)? I browsed the source of package
'base' (R v1.4.1 WinMe) and I found the following in help():

   .Internal(show.help.item(file, 1, ""))

but I couldn't get it to load "result.html", which is in the current
directory and also, since it is not documented I don't know if this is a
cross-platform function or even safe to use.

Suggestions?

Henrik Bengtsson

Dept. of Mathematical Statistics @ Centre for Mathematical Sciences
Lund Institute of Technology/Lund University, Sweden (+2h UTC)
Office: P316, +46 46 222 9611 (phone), +46 46 222 4623 (fax)
h b @ m a t h s . l t h . s e, http://www.maths.lth.se/bioinformatics/


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 7 Mar 2002, Henrik Bengtsson wrote:

            
(Browsing the help files might be more use.)
In Windows, use shell.exec("result.html"), which is documented.  (It looks
like `file' needs to be an absolute path, e.g. "c:/R/result.html".)

There is no cross-platform way that we know of. On Unix help.start uses a
system() call to launch netscape.
#
Henrik,

I have actually just started a function in the report writing library
I'm working on which does this.  All I really did was rip off code from
help.start.  The key part is the system call at the bottom of the
function.  Problem is, this is not portable (as others have mentioned).
If you come across a better way of doing this, let me know.

Zed A. Shaw
On Thu, 2002-03-07 at 11:07, Henrik Bengtsson wrote:
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Ok, so here is something that works for windows and unix
openBrowser <- function (query) 
{
    OST <- .Platform$OS.type
    if (OST == "windows") {
        shell.exec(query)
    }
    else if (OST == "unix") {
        if (is.null(getOption("browser"))) 
            stop("options(\"browser\") not set")
        browser <- getOption("browser")
        system(paste(browser, " -remote \"openURL(", query, ")\"
	2>/dev/null || ", 
            browser, " ", query, " &", sep = ""))
    }
    else {
        msg <- paste("don't know how to open the browser on", 
            OST)
        stop(msg)
    }
    return(NULL)
}
On Thu, Mar 07, 2002 at 09:22:49PM -0800, Zed Shaw wrote: