This FAQ is for the Windows port of R: it describes features specific to that version. The main R FAQ can be found at
There have been two versions of R for Windows, but only is under active
development, that described here. It is often called something like
rw1001 (although not officially). The information here applies
only to recent versions (
rw0901 or later).
There is also information on the use of R for Windows in the Venables & Ripley `R Complements' at http://www.stats.ox.ac.uk/pub/MASS2.
Go to any CRAN site (see http://cran.r-project.org/mirrors.html
for a list), navigate to the
directory and collect the files you need. You will need at least the
rwXxxxb1.zip rwXxxxb2.zip rwXxxxh.zip (text help) or rwXxxxch.zip (Compiled HTML help)
and you may want
rwXxxxwh.zip (the Windows help files) or
rwXxxxw.zip (the HTML format help files),
LaTeX format help files, used for offline printing), or
rwXxxxd?.zip (the draft manuals, in PDF).
Optionally, you can download the installer,
First, you need Windows 95 or 98 or NT4 or 2000: Windows 3.11+win32s will not work. Your file system must allow long file names (as is likely except perhaps for some network-mounted systems).
The simplest way is to run the installer (double-click on the icon for
rwinst.exe and navigate its wizard-like pages). Alternatively, choose
a location and unzip the zip files (with a tool that preserves long
file names and the directory structure: we recommend the INFO-ZIP
unzip). All the files will unpack into a directory called
rwXxxx, for some
Choose a working directory for R. Make a shortcut to
rwXxxx\bin\Rgui.exe on your desktop or somewhere on the Start menu
file tree. Right-click the shortcut, select Properties... and change
the `Start in' field to your working directory.
You may also want to add command-line arguments at the end of the
Target field. We use
--vsize=10M --nsize=400k. You can also set
environment variables at the end of the Target field, for
Just double-click on the shortcut you prepared at installation.
If you want to set up another project, make a new shortcut or use the existing one, and change the `Start in' field of the Properties.
Create a separate shortcut for each project: see Q2.3. All the paths to files used by R are relative to the starting directory, so setting the `Start in' field automatically helps separate projects.
It depends what you want to print.
File | Print.
RHOME\bin\helpPRINT.batand have latex installed you can print help files by
No, but you can set up a batch file using
rterm.exe. A sample batch file
might contain (as one line)
path_to_R\bin\rterm.exe --vsize=10M --nsize=500k --no-restore --no-save < %1 > %1.out
Yes. The latest versions of ESS (e.g. 5.1.13) come with support for this
version of R, and there is support for interrupting the R process from
For help with ESS, please send email to ESSemail@example.com, not the R mailing lists.
Several places in the documentation use these terms.
The working directory is the directory from which
Rterm was launched, unless a shortcut was used when it is given
by the `Start in' field of the shortcut's properties. You can find this
from R code by the call
The home directory is set as follows:
If environment variable
R_USER is set, its value is used.
Otherwise if environment variable
HOME is set, its value is used.
Otherwise if environment variables
HOMEPATH are set,
the value is
If all of these fail, the current working directory is used.
You can find this from R code by
Yes, of course. The easy way is to see if a pre-compiled binary version
of the package is available: look on CRAN at
bin/windows/windows-NT/contrib. If there is, download the zip
file and unpack it in the
rwXxxx\library directory, using
unzip or similar, or using the installer
Perhaps even easier is to use the R function
check out its help page.
If there is not a binary version or that is not up-to-date or you prefer
compiling from source, get
rwXxxxsp.zip from the distribution
(see Q1.1) and unpack it in
README.packages. You will need to collect and install
several tools to use this. Once you have done so, installation is easy:
make pkg-pkgname. To check the package (run all the examples
on its help pages) use
You can install packages anywhere and use the environment variable
R_LIBS to point to the library location(s). You can also set the
.lib.loc in your
.Rprofile or when running R.
Suppose your packages are installed in
p:\mylibs. Then you can EITHER
set R_LIBS to p:\mylibs
OR put in the
.Rprofile in the working directory or your home directory
.lib.loc <- c("p:/mylibs", .Library)
OR use a package by, e.g.
How you set an environment variable is system specific: in Windows 9x
you can set them in autoexec.bat or in an MS-DOS window from which you
Rterm. Under Windows NT/2000 you can use the
control panel or the properties of `My Computer'. You can also set them
on the command line, for example in the shortcut you could have
path_to_R\bin\rgui.exe --vsize=10M R_LIBS=e:/R/library
and you can set variables in a file
.Renviron in the working directory
or your home directory, for example
R_LIBS=e:/R/library R_VSIZE=10M R_NSIZE=400k
The order of precedence is the command line (flags before variables)
.Renviron then the inherited environment.
You can also build packages from anywhere to anywhere, but may be simpler to install a private copy of R to do the building.
HTML help only works for packages installed in
To update the HTML help files after you have installed a binary package, run at the R prompt.
install.packages() does this for you. The source-code
installation also does this automatically, and if you have that
installed you can use (preferably)
cd rwXxxx\src\gnuwin32\help make indices
The following conditions need to hold for functions in a package you installed.
CONTENTSfile in top-level directory (a few of the binary distributions do not).
If those all hold true, this works for us.
rgui.exeand <Ctrl-break> or <Ctrl-C> in
rterm.exe: <Ctrl-C> is used for copying in the GUI version.
rgui.exe, the menu item `Help | Console' will give details.
rgui.exe, and it is always saved.
help.start()does not automatically send help requests to the browser: use
options(htmlhelp=T)to turn this on.
source()) can be specified with either "/" or "\\".
system()is slightly different: see its help page and that of
You have read the
README? There are file menus on the R console,
pager and graphics windows. You can source and save from those menus,
and copy the graphics to
metafile. There are right-click menus giving
shortcuts to menu items, and optionally toolbars with buttons giving
shortcuts to frequent operations.
If you resize the R console the
options(width=) is automatically
set to the console width (unless disabled in the configuration file).
The graphics has a history mechanism. As the README says:
`The History menu allows the recording of plots. When plots have been recorded they can be reviewed by <PgUp> and <PgDn>, saved and replaced. Recording can be turned on automatically (the Recording item on the list) or individual plots can be added (Add or the <INS> key). The whole plot history can be saved to or retrieved from an R variable in the global environment.
There is only one graphics history shared by all the windows devices.'
The R console and graphics windows have configuration files stored in the
RHOME\etc directory called
Rdevga; you can
keep personal copies in your
HOME directory. They contain comments which
should suffice for you to edit them to your preferences. For more details
Have you changed the working directory?: see Q5.2.
Use the `File | Change Dir' menu item to select a new working directory: this defaults to the last directory you loaded a file from. The workspace is saved in the working directory. You can also save a snapshot of the workspace from the `Save Image' menu item.
Yes. The converse (saving on Windows, loading on Unix) also works.
for example, in the console and to annotate graphs.
We believe this is possible by setting suitable fonts in the Rconsole and Rdevga configuration files (see Q4.2). You can specify additional fonts in Rdevga, and use them by
par(font=, font.lab=, font.main=, font.sub=)
Nineteen fonts are specified (as 1 to 19) by default: you can add to these (up to 13 more) or replace them.
You need to specify a font in Rconsole (see Q4.2) that supports latin1 encoding. The default, Courier New, does on our systems, as does FixedSys. This may be a problem in other locales, especially for non-Western European languages.
This is deliberate: the console output is buffered and re-written in chunks to be less distracting. You can turn buffering off or on from the Misc menu or the right-click menu: <Ctrl-W> toggles the setting.
If you are sourcing R code or writing from a function, there is another
option. A call to the R function
flush.console() will write out
the buffer and so update the console.
They only seem to be truncated: that $ at the end indicates you
can scroll the window to see the rest of the message. Use the
<CTRL+arrow> keys to scroll horizontally, or (
later) use the horizontal scrollbar.
Get the R sources. Suppose you want to compile R-1.0.1.
tar zxvf R-1.0.1.tgz cd R-1.0.1 cd src\gnuwin32
Now read the
INSTALL file and set up all the tools needed. Then you
can just use
make, sit back and wait. (A complete build takes about
15 minutes on a 300MHz PII with a fast local disc.)
You may need to compile under a case-honouring file system: we found
samba-mounted file system (which maps all file names to lower
case) did not work.
First, build a version of the R system with debugging information by
make clean make DEBUG=T
and make a debug version of your package by
make DEBUG=T pkg-mypkg
Then you can debug by
rwXxxx/src/gnuwin32for the main system,
rwXxxx/src/library/mypkg/srcfor a package), unless told otherwise by the
directorycommand. It is most convenient to set a list of code locations via
directorycommands in the file
.gdbinitin the directory from which
gdb ../../../../bin/Rgui.exe (gdb) break WinMain (gdb) run [ stops with R.dll loaded ] (gdb) break R_ReadConsole (gdb) continue [ stops with console running ] (gdb) continue Rconsole> library(eda) (gdb) break tukeyline (gdb) clear R_ReadConsole (gdb) continue
Fortran symbols need an underline appended.
gdb. It does often work with the
cygwin gdbwas able to catch but which terminated the
If you have an X server available on the PC, there is a version of
available that runs under the cygwin emulation layer (follow the links
at http://sourceware.cygnus.com/cygwin) and provides a graphical
user interface to
gdb. Another (Windows-native) GUI for
You need to do two things:
(a) Write a wrapper to export the symbols you want to call from R as
(b) Include the C++ libraries in the link to make the DLL. Suppose
X.cc contains your C++ code, and
X_R.cc is the
wrapper. Then build the DLL by (
g++ -c X.cc X_R.cc dlltool --export-all-symbols --output-def X.def X_R.o dllwrap -o X.dll --def X.def X.o X_R.o -lstdc++
cl /MT /c X.cpp X_R.cpp link /dll /out:XX.dll /export:X_main X.obj X_R.obj
and call the entry point(s) in
X_R. Construction of static variables
will occur when the DLL is loaded, and destruction when the DLL is
unloaded, usually when R terminates.
Rgui.exe console is a Windows application: writing to
stderr will not produce output in the
console. (This will work with
REprintf instead. These are declared in header file
Writing to Fortran output writes to a file, not the
Use one of the subroutines
documented in the `Writing R Extensions' manual.