views:

253

answers:

1

I started using Emacs (ESS) as a default R editor (yes, @Dirk, as you've said, I want ESS), and I must admit it's by far the best R editor I've been using so far. However, I cannot manage to get an output of help() function up to web browser. It keeps displaying help page in a separate R buffer, even if options(help_type = "html", browser = "firefox") are set.

How can I get help back to browser, while using Emacs/ESS?

+4  A: 

I can reproduce this under Linux: If I run R from the terminal, setting options(htmlhelp=TRUE) brings up help in a browser, but it fails from ESS. However,

help("plot",htmlhelp=getOption("htmlhelp"))

works -- help opens in Firefox for me. I think that's an anomalous behavior -- htmlhelp=getOption("htmlhelp") is a default argument for help (see ?help). Could it be a bug?.. A possible workaround is to invoke help via help("plot",htmlhelp=T) directly, or write a wrapper like myhelp <- function(x) help(x,htmlhelp=TRUE).

EDIT: A possible solution: put this into your .emacs

(setq inferior-ess-r-help-command "help(\"%s\", htmlhelp=TRUE)\n")

as per https://stat.ethz.ch/pipermail/ess-debian/2009-October/000093.html. This refers to ESS 5.5; the current one in Ubuntu repositories is 5.4, so I can't test the fix w/o upgrading ESS.

EDIT2: I upgraded to the latest R/ESS as per Dirk's suggestion, and did the following, after launching R/ESS: M-x customize variable inferior-ess-r-help-command and replaced help_type=text with help_type=html. That fixed things (at least for version 2.10.1/ESS 5.8).

Leo Alekseyev
ESS 5.8 is available for Ubuntu _if_ you use the apt-get'able repo at CRAN -- see $CRAN/bin/linux/ubuntu
Dirk Eddelbuettel
@Leo, thanks for workaround, it works for me. Could you, please be more precise with the location of an `.emacs` file? I've tried `locate .emacs` but with no luck... BTW, I thought that `option(htmlhelp = TRUE)` was deprecated in R v2.10.x, if not since v2.9.x ?!
aL3xa
Yup, the link that I posted was discussing 2.9, I believe. I just figured out a clean way to do this w/o editing .emacs -- see my updated edit2. But to figure out where your .emacs is, do C-h v user-init-file, this gives the value of the variable where path to the file is stored. Typically it is either ~/.emacs or ~/.emacs.d/init.el (but people still refer to it as .emacs)
Leo Alekseyev
Great! And now ~/.emacs file was created. But there's a downside: help page is opened in Opera, although Firefox is default.
aL3xa
Run C-h v browse-url-browser-function, is that set to Opera or FF? If opera, try customizing it so that its value is browse-url-firefox.
Leo Alekseyev
Sorry, it had to do something with E17 environment settings... after changing it in E17, it works fine with Firefox. Thanx a lot mate!
aL3xa