This FAQ is for the Windows port of R: it describes features specific to that version. The main R FAQ can be found at http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html.
There are two versions of R for Windows, but only is under active development, that described here. It is often called something like rw0901 (although not officially). The information here applies only to recent versions (rw0642 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.
rw0xxxb1.zip rw0xxxb2.zip rw0xxxh.zip (text help) or rw0xxxch.zip (Compiled HTML help)and you may want rw0xxxw.zip (the HTML format help files) or rw0xxxwh.zip (the Windows help files), rw0xxxl.zip (the LaTeX format help files, used for offline printing), or rw0xxxd.zip (the draft manuals, in PDF).
Optionally, you can download the installer, rwinst.exe.
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 project's unzip). All the files will unpack into a directory called rw0xxx, for some `xxx'.
Choose a working directory for R. Make a shortcut to rw0xxx\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 example R_LIBS=e:/R/library.
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.
dev.print()
.path_to_R\bin\rterm.exe --vsize 10M --nsize 300k --no-restore --no-save < %1 > %1.out
Yes. The latest versions of ESS (e.g. 5.1.11) come with support for this version of R, and rw0650 and later have support for interrupting the R process from ESS (by C-c C-c).
For help with ESS, please send email to
ESS-help@stat.ethz.ch
,
not the R mailing lists.
Several places in the documentation use these terms.
The working directory is the directory from which Rgui or 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 getwd().
The home directory is set as follows (rw0650 on).
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 HOMEDRIVE and HOMEPATH are set, the value is ${HOMEDRIVE}${HOMEPATH}. If all of these fail, the current working directory is used.
You can find this from R code by getenv("R_USER").
If there is not a binary version or that is not up-to-date or you prefer compiling from source, get rw0xxxsp.zip from the distribution (see Q1.1) and unpack it in rw0xxx. Then cd src\gnuwin32 and read README.packages. You will need to collect and install several tools to use this. Once you have done so, installation is easy: just run `make pkg-pkgname'. To check the package (run all the examples on its help pages) use `make pkgcheck-pkgname'.
You can install packages anywhere and use the environment variable R_LIBS to point to the library location(s). You can also set the R variable `.lib.loc' in your .Rprofile or when running R.
Suppose your packages are in installed in p:\mylibs. Then you can EITHER
set RLIBS 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.
library(MASS, lib.loc="p:/mylibs")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 launch Rgui/Rterm. Under Windows NT you can use the control panel. 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 --nsize 400k R_LIBS=e:/R/libraryand 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=400kThe order of precedence is the command line then .Renviron then the inherited environment.
You can also build packages anywhere, but that is much trickier: it is simpler to install a private copy of R to do the building.
To update the HTML help files after you have installed a binary package, run at the R prompt
> link.html.help()(The source-code installation does this automatically, and if you have that installed you can use (preferably)
cd rw0xxx\src\gnuwin32\help make indicesinstead.)
`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 x11 devices.'
The R console and graphics windows have configuration files stored in the RHOME\etc directory called Rconsole and 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 see ?Rconsole.
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.
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.
tar zxvf R-0.90.1.tgz cd R-0.90.1 cd src\gnuwin32Now 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 that a 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=Tand make a debug version of your package by
make DEBUG=T pkg-mypkgThen you can debug by
gdb /path/to/rw0xxx/bin/Rgui.exeHowever, note
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) continueFortran symbols need an underline appended.
You need to do two things:
(a) Write a wrapper to export the symbols you want to call from R as extern "C".
(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 (gcc-2.95.x)
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++
or (VC++)
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.
The Rgui.exe console is a Windows application: writing to stdout or stderr will not produce output in the console. (This will work with Rterm.exe.) Use Rprintf instead.
ripley@stats.ox.ac.uk