Force R help HTML server to always use the same URL port

October 22, 2012

(This article was first published on jottR, and kindly contributed to R-bloggers)

The below code shows how to configure the ‘help.ports’ option in R such that the built-in R help server always uses the same URL port. Just add it to the .Rprofile file in your home directory (iff missing, create it). For more details, see help(“Startup”).

# Force the URL of the help to

A slighter fancier version is to use a environment variable to set the port(s):

ports <- Sys.getenv("R_HELP_PORTS", 21510);
ports <- as.integer(unlist(strsplit(ports, ",")));

However, if you launch multiple R sessions in parallel, this means that they will all try to use the same port, but it’s only the first one that will success and all other will fail.  An alternative is then to provide R with a set of ports to choose from (see help(“startDynamicHelp”, package=”tools”)). To set the ports to 21510-21519 if you run R v2.15.1, to 21520-21529 if you run R v2.15.2, to 21600-21609 if you run R v2.16.0 (“devel”) and so on, do:

port <- sum(c(1e4,100)*as.double(R.version[c("major", "minor")]));

With this it will be easy from the URL to identify for which version of R the displayed help is for. Finally, if you wish the R help server to start automatically in the background when you start R, add:

# Try to start HTML help server
if (interactive()) {

To leave a comment for the author, please follow the link and comment on their blog: jottR. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)