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

Robert Gentleman rgentlem at jimmy.harvard.edu
Fri Mar 8 13:16:05 CET 2002


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:
> 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:
> > 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
> > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
+---------------------------------------------------------------------------+
| Robert Gentleman                 phone : (617) 632-5250                   |
| Associate Professor              fax:   (617)  632-2444                   |
| Department of Biostatistics      office: M1B28
| Harvard School of Public Health  email: rgentlem at jimmy.dfci.harvard.edu   |
+---------------------------------------------------------------------------+
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list