Rev 14765 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html lang="en"><head><meta name="generator" content="HTML Tidy, see www.w3.org"><title>R for Windows FAQ</title><meta http-equiv="Content-Type" content="text/html"><meta name="description" content="R for Windows FAQ"><meta name="generator" content="makeinfo 4.0"><link href="http://texinfo.org/" rel="generator-home"><title>R for Windows FAQ</title></head><body><h1 align="center">R for Windows FAQ</h1><h2>Version for <tt>rw1040</tt></h2><address>B. D. Ripley</address><hr><p></p><h1>Table of Contents</h1><ul><li><a href="#Introduction">1 Introduction</a></li><li><a href="#Installation%20and%20Usage">2 Installation andUsage</a><ul><li><a href="#Where%20can%20I%20find%20the%20latest%20version%3f">2.1 Where canI find the latest version?</a></li><li><a href="#How%20do%20I%20install%20R%20for%20Windows%3f">2.2How do I install R for Windows?</a></li><li><a href="#How%20do%20I%20run%20it%3f">2.3 How do I runit?</a></li><li><a href="#There%20seems%20to%20be%20a%20limit%20on%20the%20memory%20it%20uses!">2.4 There seems to be a limit on the memory it uses!</a></li><li><a href="#How%20can%20I%20keep%20workspaces%20for%20different%20projects%20in%20different%20directories%3f">2.5 How can I keep workspaces for different projects in differentdirectories?</a></li><li><a href="#How%20do%20I%20print%20from%20R%3f">2.6 How do Iprint from R?</a></li><li><a href="#Can%20I%20use%20R%20BATCH%3f">2.7 Can I use <code>RBATCH</code>?</a></li><li><a href="#Can%20I%20use%20rw1040%20with%20ESS%20and%20emacs%3f">2.8 Can Iuse rw1040 with ESS and emacs?</a></li><li><a href="#What%20are%20HOME%20and%20working%20directories%3f">2.9 What areHOME and working directories?</a></li><li><a href="#R%20can't%20find%20my%20file">2.10 R can't find myfile, but I know it is there!</a></li><li><a href="#Does%20R%20use%20the%20Registry%3f">2.11 Does R usethe Registry?</a></li><li><a href="#Entering%20certain%20characters%20crashes%20Rgui.">2.12 Enteringcertain characters crashes Rgui.</a></li></ul></li><li><a href="#Packages">3 Packages</a><ul><li><a href="#Can%20I%20install%20packages%20(libraries)%20in%20this%20version%3f">3.1 Can I install packages (libraries) in this version?</a></li><li><a href="#I%20don't%20have%20permission%20to%20write%20to%20the%20rw1040%5clibrary%20directory">3.2 I don't have permission to write to the<code>rw1040\library</code> directory.</a></li><li><a href="#The%20packages%20I%20installed%20do%20not%20appear%20in%20the%20HTML%20help%20system">3.3 The packages I installed do not appear in the HTML helpsystem.</a></li><li><a href="#My%20functions%20are%20not%20found%20by%20the%20HTML%20help%20search%20system.">3.4 My functions are not found by the HTML help searchsystem.</a></li><li><a href="#Loading%20a%20package%20fails.">3.5 Loading a packagefails.</a></li><li><a href="#Package%20TclTk%20does%20not%20work.">3.6 PackageTclTk does not work.</a></li><li><a href="#Hyperlinks%20in%20Compiled%20HTML%20do%20not%20work.">3.7Hyperlinks in Compiled HTML sometimes do not work.</a></li></ul></li><li><a href="#Windows%20Features">4 Windows Features</a><ul><li><a href="#What%20should%20I%20expect%20to%20behave%20differently%20from%20the%20Unix%20version">4.1 What should I expect to behave differently from the Unixversion of R?</a></li><li><a href="#I%20hear%20about%20some%20nifty%20features.">4.2 Ihear about some nifty features: please tell me about them!</a></li><li><a href="#Circles%20appear%20as%20ovals%20on%20screen">4.3Circles appear as ovals on screen</a></li><li><a href="#How%20do%20I%20more%20focus%20to%20a%20graphics%20window%20or%20the%20console%3f">4.4 How do I more focus to a graphics window or theconsole?</a></li></ul></li><li><a href="#Workspaces">5 Workspaces</a><ul><li><a href="#My%20workspace%20gets%20saved%20in%20a%20strange%20place.%20How%20do%20I%20stop%20this%3f">5.1 My workspace gets saved in a strange place: how do I stopthis?</a></li><li><a href="#How%20do%20I%20store%20my%20workspace%20in%20a%20different%20place%3f">5.2 How do I store my workspace in a different place?</a></li><li><a href="#Can%20I%20load%20workspaces%20saved%20under%20Unix%2fGNU-Linux%3f">5.3 Can I load workspaces saved under Unix/GNU-Linux?</a></li></ul></li><li><a href="#The%20R%20Console%20and%20Fonts">6 The R Console andFonts</a><ul><li><a href="#I%20would%20like%20to%20be%20able%20to%20use%20Japanese%20fonts">6.1I would like to be able to use Japanese fonts</a></li><li><a href="#I%20don't%20see%20characters%20with%20accents%20at%20the%20R%20console">6.2 I don't see characters with accents at the R console, forexample in ?text.</a></li><li><a href="#The%20output%20to%20the%20console%20seems%20to%20be%20delayed">6.3When using Rgui the output to the console seems to bedelayed.</a></li><li><a href="#Long%20lines%20seem%20to%20be%20truncated.">6.4 Longlines in the console or pager are truncated.</a></li></ul></li><li><a href="#Building%20from%20Source">7 Building from Source</a><ul><li><a href="#How%20can%20I%20compile%20R%20from%20source%3f">7.1How can I compile R from source?</a></li><li><a href="#How%20do%20I%20include%20compiled%20C%20code%3f">7.2How do I include compiled C code?</a></li><li><a href="#How%20do%20I%20debug%20code%20that%20I%20have%20compiled%20and%20dyn.load-ed%3f">7.3 How do I debug code that I have compiled anddyn.load-ed?</a></li><li><a href="#How%20do%20I%20include%20C++%20code%3f">7.4 How do Iinclude C++ code?</a></li><li><a href="#The%20output%20from%20my%20C%20code%20disappears.">7.5 The outputfrom my C code disappears. Why?</a></li><li><a href="#The%20output%20from%20my%20Fortran%20code%20disappears.">7.6 Theoutput from my Fortran code disappears. Why?</a></li><li><a href="#The%20console%20freezes%20when%20my%20compiled%20code%20is%20running">7.7 The console freezes when my compiled code is running.</a></li><li><a href="#The%20Perl%20scripts%20don't%20seem%20to%20work%20under%20Windows%209x%2fME">7.8 The Perl scripts don't seem to work under Windows9x/ME</a></li></ul></li></ul><a name="Top"></a><hr><a name="Introduction"></a><h1>1 Introduction</h1><p>This FAQ is for the Windows port of R: it describes featuresspecific to that version. The main R FAQ can be found at</p><pre><a href="http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html">http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html</a>.</pre><p>The information here applies only to recent versions of R forWindows, (<code>rw1020</code> or later); the current version isoften called something like <code>rw1040</code> (although notofficially).</p><hr><a name="Installation%20and%20Usage"></a><h1>2 Installation and Usage</h1><a name="Where%20can%20I%20find%20the%20latest%20version%3f"></a><h2>2.1 Where can I find the latest version?</h2><p>Go to any CRAN site (see <a href="http://cran.r-project.org/mirrors.html">http://cran.r-project.org/mirrors.html</a>for a list), navigate to the <code>bin/windows/base</code>directory and collect the files you need. There are threepossibilities.</p><p>1) <code>SetupR.exe</code>, is about 15Mb and gives a completeinstallation.</p><p>2) Directory <code>miniR</code> contains <code>miniR.exe</code>and six files <code>miniR-?.bin</code>. You can put<code>miniR.exe</code> and <code>miniR-1.bin</code> on one floppyand the remaining <code>miniR-?.bin</code> on a floppy each.</p><p>3) Via zip files in directory <code>zip</code>. You will need atleast the files</p><pre>rw1040b1.zip rw1040b2.ziprw1040h.zip (text help) or rw1040ch.zip (Compiled HTML help)</pre><p>and you may want <code>rw1040w.zip</code> (the HTML format helpfiles), <code>rw1040l.zip</code> (the LaTeX format help files, usedfor offline printing), or <code>rw1040d?.zip</code> (the draftmanuals, in PDF). <a name="How%20do%20I%20install%20R%20for%20Windows%3f"></a></p><h2>2.2 How do I install R for Windows?</h2><p>First, you need Windows 95/98/ME/NT4/2000: Windows 3.11+win32swill not work. Your file system must allow long file names (as islikely except perhaps for some network-mounted systems).</p><p>The simplest way is to use <code>SetupR.exe</code> or<code>miniR.exe</code>. Just double-click on the icon and followthe instructions. If you installed R this way you can uninstall itfrom the Control Panel or Start Menu (unless you supressed making agroup for R).</p><p>For a manual installation, choose a location and unzip the zipfiles (with a tool that preserves long file names and the directorystructure: we recommend the INFO-ZIP project's <code>unzip</code>).All the files will unpack into a directory <code>rw1040</code>.</p><p>Choose a working directory for R. Unless you used<code>SetupR.exe</code> or <code>miniR.exe</code> (which did thisfor you by default), make a shortcut to<code>rw1040\bin\Rgui.exe</code> on your desktop or somewhere onthe Start menu file tree. Right-click the shortcut, selectProperties... and change the `Start in' field to your workingdirectory.</p><p>You may also want to add command-line arguments at the end ofthe Target field, for example <code>--sdi--max-mem-size=40M</code>. You can also set environment variablesat the end of the Target field, for example<code>R_LIBS=p:/R/library</code>. <a name="How%20do%20I%20run%20it%3f"></a></p><h2>2.3 How do I run it?</h2><p>Just double-click on the shortcut you prepared atinstallation.</p><p>If you want to set up another project, make a new shortcut oruse the existing one and change the `Start in' field of theProperties. <a name="There%20seems%20to%20be%20a%20limit%20on%20the%20memory%20it%20uses!"></a></p><h2>2.4 There seems to be a limit on the memory it uses!</h2><p>Indeed there is. It is set by the command-line flag<code>--max-mem-size</code> and defaults to the smaller of theamount of physical RAM in the machine and 256Mb. It can be set toany amount over 10M. Be aware though that Windows has (in mostversions) a maximum amount of user virtual memory of 2Gb, and partsof this can be reserved by processes but not used. R itselfreserves 256Mb on startup. Because of the way the memory managerworks, it is possible that there will be free memory but R will notbe able to reserve it.</p><p>Use <code>?Memory</code> and <code>?memory.size</code> forinformation about memory usage.</p><p>R can be compiled to use a different memory manager which may bebetter at using large amounts of memory, but is substantiallyslower (making R several times slower on some tasks). <a name="How%20can%20I%20keep%20workspaces%20for%20different%20projects%20in%20different%20directories%3f"></a></p><h2>2.5 How can I keep workspaces for different projects indifferent directories?</h2><p>Create a separate shortcut for each project: see Q2.3. All thepaths to files used by R are relative to the starting directory, sosetting the `Start in' field automatically helps separateprojects.</p><p>Alternatively, start R by double-clicking on a saved<code>.RData</code> file in the directory for the project you wantto use, or drag-and-drop a file with extension <code>.RData</code>onto an R shortcut. In either case, the working directory will beset to that containing the file. <a name="How%20do%20I%20print%20from%20R%3f"></a></p><h2>2.6 How do I print from R?</h2><p>It depends what you want to print.</p><ul><li>You can print the graphics window from its menu or by using<code>dev.print()</code>.</li><li>You can print from the R console or pager by <code>File |Print</code>. (This will print the selection if there is one,otherwise the whole console or pager contents.)</li><li>You can print help files from the pager or HTML browser.</li><li>If you have configured <code>RHOME\bin\helpPRINT.bat</code> andhave LaTeX installed you can print help files by<code>help(fn_name, offline=TRUE)</code>.</li></ul><a name="Can%20I%20use%20R%20BATCH%3f"></a><h2>2.7 Can I use <code>R BATCH</code>?</h2><p>Yes, if you have Perl and the files for making source packages(from <code>SetupR.exe</code> or <code>rw1040sp.zip</code>)installed. The Windows analogue is <code>Rcmd BATCH</code>: use<code>Rcmd BATCH --help</code> for full details.</p><p>Otherwise you can set up a batch file using<code>Rterm.exe</code>. A sample batch file might contain (as oneline)</p><pre>path_to_R\bin\Rterm.exe --no-restore --no-save < %1 > %1.out</pre><a name="Can%20I%20use%20rw1040%20with%20ESS%20and%20emacs%3f"></a><h2>2.8 Can I use rw1040 with ESS and emacs?</h2><p>Yes. The latest versions of ESS (e.g. 5.1.18) come with supportfor this version of R, and there is support for interrupting the Rprocess from ESS (by <code>C-c C-c</code>).</p><p>For help with ESS, please send email to <a href="mailto:ESS-help@stat.ethz.ch">ESS-help@stat.ethz.ch</a>, not the Rmailing lists. <a name="What%20are%20HOME%20and%20working%20directories%3f"></a></p><h2>2.9 What are HOME and working directories?</h2><p>Several places in the documentation use these terms.</p><p>The working directory is the directory from which<code>Rgui</code> or <code>Rterm</code> was launched, unless ashortcut was used when it is given by the `Start in' field of theshortcut's properties. You can find this from R code by the call<code>getwd()</code>.</p><p>The home directory is set as follows:<br>If environment variable <code>R_USER</code> is set, its value isused.<br>Otherwise if environment variable <code>HOME</code> is set, itsvalue is used.<br>Otherwise if environment variables <code>HOMEDRIVE</code> and<code>HOMEPATH</code> are set, the value is<code>${HOMEDRIVE}${HOMEPATH}</code>.<br>If all of these fail, the current working directory is used.</p><p>You can find this from R code by<code>Sys.getenv("R_USER")</code>. <a name="R%20can't%20find%20my%20file"></a></p><h2>2.10 R can't find my file, but I know it is there!</h2><p>How did you specify it? Backslashes have to be doubled in Rcharacter strings, so for example one needs<code>"d:\\rw1030\\library\\xgobi\\scripts\\xgobi.bat"</code>. Makelife easier for yourself by using forward slashes as pathseparators: they do work under Windows.</p><p>Another possible source of grief is spaces in folder names. Wehave tried to make R work on paths with spaces in, but lots ofpeople writing packages for Unix do not bother. So it is worthtrying the alternative short name (something like<code>PROGRA~1</code>; you can get it as the `MS-DOS name' from theProperties of the file on most versions of Windows). <a name="Does%20R%20use%20the%20Registry%3f"></a></p><h2>2.11 Does R use the Registry?</h2><p>Not itself.</p><p>The installers set some entries to allow uninstallation. Inaddition they set a Registry key<code>LOCAL_MACHINE\Software\R-core\R</code> giving the version andinstall path. Again, this is not used by R itself, but it will beused by the DCOM interface (<a href="http://cran.r-project.org/other-software.html">http://cran.r-project.org/other-software.html</a>).Finally, a file association for extension <code>.RData</code> isset in the Registry.</p><p>You can add the Registry entries by running<code>RSetReg.exe</code> in the <code>bin</code> folder, and removethem by running this with argument <code>/U</code>. Note that thesettings are all per machine and not per user, and that thisneither sets up nor removes the file associations. <a name="Entering%20certain%20characters%20crashes%20Rgui."></a></p><h2>2.12 Entering certain characters crashes Rgui.</h2><p>This seems to happen occasionally, and all the occurrences wehave solved have been traced to faulty versions of<code>msvcrt.dll</code>. Try extracting the one to be found in theself-extracting archive <a href="ftp://ftp.microsoft.com/softlib/mslfiles/msvcrt.exe">ftp://ftp.microsoft.com/softlib/mslfiles/msvcrt.exe</a>and put it in the <code>rw1040\bin</code> directory. Removing<code>msvcrt.dll</code> from that directory reverts to the standardbehaviour.</p><p>This fix has solved other problems too, for example incorrectresults in the date-time functions.</p><hr><a name="Packages"></a><h1>3 Packages</h1><a name="Can%20I%20install%20packages%20(libraries)%20in%20this%20version%3f"></a><h2>3.1 Can I install packages (libraries) in this version?</h2><p>Yes, but you will need a lot of tools to do so, unless theauthor or the maintainers of the <code>bin/windows/contrib</code>section on CRAN has been kind enough to provide a pre-compiledversion for Windows as a <code>.zip</code> file.</p><p>You can install pre-compiled packages either from CRAN or from alocal <code>.zip</code> file by using<code>install.packages</code>: see its help page. There are menuitems on the <code>Packages</code> menu to provide apoint-and-click interface to package installation.</p><p>Note that the pre-compiled versions on CRAN are unsupported: see<a href="http://cran.r-project.org/bin/windows/contrib/ReadMe">http://cran.r-project.org/bin/windows/contrib/ReadMe</a>.</p><p>If there is not a pre-compiled version or that is not up-to-dateor you prefer compiling from source, get <code>rw1040sp.zip</code>from the distribution (see Q1.1; you may already have installedthis from <code>SetupR.exe</code>) and unpack it in the parent of<code>rw1040</code>. Then read the file<code>readme.packages</code>. You will need to collect and installseveral tools to use this. Once you have done so, just run<code>Rcmd INSTALL pkgname</code>. To check the package (includingrunning all the examples on its help pages and in its test suite,if any) use <code>Rcmd check pkgname</code>: see the <em>`Writing RExtensions'</em> manual. <a name="I%20don't%20have%20permission%20to%20write%20to%20the%20rw1040%5clibrary%20directory"></a></p><h2>3.2 I don't have permission to write to the<code>rw1040\library</code> directory.</h2><p>You can install packages anywhere and use the environmentvariable <code>R_LIBS</code> to point to the library location(s).You can also set the R variable <code>.lib.loc</code> in your<code>.Rprofile</code> or when running R.</p><p>Suppose your packages are installed in <code>p:\mylibs</code>.Then you can EITHER</p><pre>set the environment variable R_LIBS to p:\mylibs</pre><p>OR put in the <code>.Rprofile</code> in the working directory oryour home directory</p><pre>.lib.loc <- c("p:/mylibs", .Library)</pre><p>OR use a package by, e.g.</p><pre>library(MASS, lib.loc="p:/mylibs")</pre><p>How you set an environment variable is system specific: inWindows 9x you can set them in <code>autoexec.bat</code> or in anMS-DOS window from which you launch <code>Rgui</code> /<code>Rterm</code>. Under Windows NT/2000 you can use the controlpanel or the properties of `My Computer'. Under Windows Me you needto use the System Configuration Utility (under Programs,Accessories, System Tools on the Start menu). You can also set themon the command line, for example in the shortcut you could have</p><pre>path_to_R\bin\Rgui.exe R_LIBS=p:/mylibs</pre><p>and you can set variables in a file <code>.Renviron</code> inthe working directory or your home directory, for example</p><pre>R_LIBS=p:/mylibs</pre><p>The order of precedence for environmental variables is thecommand line then <code>.Renviron</code> then the inheritedenvironment. <a name="The%20packages%20I%20installed%20do%20not%20appear%20in%20the%20HTML%20help%20system"></a></p><h2>3.3 The packages I installed do not appear in the HTML helpsystem.</h2><p>The HTML search only works for packages installed in<code>rw1040\library</code>.</p><p>To update the HTML indices after you have installed apre-compiled package, run at the R prompt.</p><pre>> link.html.help()</pre><p>This is done automatically when installing from the Packagesmenu or by <code>install.packages()</code>. <a name="My%20functions%20are%20not%20found%20by%20the%20HTML%20help%20search%20system."></a></p><h2>3.4 My functions are not found by the HTML help searchsystem.</h2><p>The following conditions need to hold for functions in a packageyou installed.</p><ul><li>the package is installed in <code>rw1040\library</code>.</li><li>the package contains a <code>CONTENTS</code> file in itstop-level directory.</li><li>you updated the indices as described in the answer to Q3.3after installing the package.</li></ul><p>If those all hold true, this works for us. <a name="Loading%20a%20package%20fails."></a></p><h2>3.5 Loading a package fails.</h2><p>Is the package compiled for this version of R? Many of thepackages need to be compiled for a fairly recent version, and inparticular a substantial minority need to be re-compiled for<code>rw1020</code> and later.</p><p>You can tell the version the package was compiled for by lookingat the <code>Built:</code> line in its <code>DESCRIPTION</code>file or at the <code>Version</code> tab of its DLL (if it has one)in the <code>libs</code> directory. (Right-click on the DLL inWindows Explorer, and select <code>Properties</code> or use the<code>DLL.version</code> function inside R.) If there is no<code>Built:</code> line or version tab, the package was compiledtoo long ago. <a name="Package%20TclTk%20does%20not%20work."></a></p><h2>3.6 Package TclTk does not work.</h2><p>For package <code>tcltk</code> to work (try<code>demo(tkdensity)</code> or <code>demo(tkttest)</code> after<code>library(tcltk)</code>) you need to have Tcl installed.Download either ActiveTcl 8.3.3 from <a href="http://aspn.activestate.com/ASPN/Downloads/ActiveTcl/">http://aspn.activestate.com/ASPN/Downloads/ActiveTcl/</a>or <code>tcl832.exe</code> from <a href="dev.scriptics.com">dev.scriptics.com</a> and install it. (Thatwill put the <code>bin</code> directory containing the Tcl and TkDLLs in your path). You then need to set the environment variable<code>TCL_LIBRARY</code>, to something like <code>c:/ProgramFiles/Tcl/lib/tcl8.3</code>. (The startup code for the package willwarn you if this is unset, and Q3.2 explains how to set them. NB:do not quote the path, even if as here it contains spaces. If youforget, you can set the variable inside R by something like</p><pre>Sys.putenv("TCL_LIBRARY"="c:/Program Files/Tcl/lib/tcl8.3")</pre>.) <a name="Hyperlinks%20in%20Compiled%20HTML%20do%20not%20work."></a><h2>3.7 Hyperlinks in Compiled HTML sometimes do not work.</h2><p>Unfortunately, hyperlinks in compiled HTML files used from R areinterpreted relative to the current working directory of the Rprocess, not relative to the <code>pkg.chm</code> file. This wasnot discovered until <code>rw1021</code>: files made before thatversion work incorrectly. Remake the package to cure this.</p><hr><a name="Windows%20Features"></a><h1>4 Windows Features</h1><a name="What%20should%20I%20expect%20to%20behave%20differently%20from%20the%20Unix%20version"></a><h2>4.1 What should I expect to behave differently from the Unixversion of R?</h2><ul><li>R commands can be interrupted by <Esc> in<code>Rgui.exe</code> and <Ctrl-break> or <Ctrl-C> in<code>Rterm.exe</code>: <Ctrl-C> is used for copying in theGUI version.</li><li>Command-line editing is always available, but is simpler thanthe readline-based editing on Unix. For <code>Rgui.exe</code>, themenu item `Help | Console' will give details. For<code>Rterm.exe</code> see file <code>README.rterm</code>.</li><li>Using <code>help.start()</code> does not automatically sendhelp requests to the browser: use<code>options(htmlhelp=TRUE)</code> to turn this on.</li><li>The HTML help system can only access packages installed in thestandard place.</li><li>Paths to files (e.g. in <code>source()</code>) can be specifiedwith either "/" or "\\".</li><li><code>system()</code> is slightly different: see its help pageand that of <code>shell()</code>.</li></ul><a name="I%20hear%20about%20some%20nifty%20features."></a><h2>4.2 I hear about some nifty features: please tell me aboutthem!</h2><p>You have read the <code>README</code>? There are file menus onthe R console, pager and graphics windows. You can source and savefrom those menus, and copy the graphics to <code>png</code>,<code>jpeg</code>, <code>bmp</code>, <code>postscript</code>,<code>PDF</code> or <code>metafile</code>. There are right-clickmenus giving shortcuts to menu items, and optionally toolbars withbuttons giving shortcuts to frequent operations.</p><p>If you resize the R console the <code>options(width=)</code> isautomatically set to the console width (unless disabled in theconfiguration file).</p><p>The graphics has a history mechanism. As the README says:</p><blockquote>`The History menu allows the recording of plots. Whenplots have been recorded they can be reviewed by <PgUp> and<PgDn>, saved and replaced. Recording can be turned onautomatically (the Recording item on the list) or individual plotscan be added (Add or the <INS> key). The whole plot historycan be saved to or retrieved from an R variable in the globalenvironment.<p>There is only one graphics history shared by all the windowsdevices.'</p></blockquote><p>The R console and graphics windows have configuration filesstored in the <code>RHOME\etc</code> directory called<code>Rconsole</code> and <code>Rdevga</code>; you can keeppersonal copies in your <code>HOME</code> directory. They containcomments which should suffice for you to edit them to yourpreferences. For more details see <code>?Rconsole</code>. There isa Preferences editor invoked from the <code>Edit</code> menu whichcan be used to edit the file <code>Rconsole</code>. <a name="Circles%20appear%20as%20ovals%20on%20screen"></a></p><h2>4.3 Circles appear as ovals on screen</h2><p>The graphics system asks Windows for the number of pixels perinch in the X and Y directions, and uses that to size graphics(which in R are in units of inches). Sometimes the answer is acomplete invention, and in any case Windows will not know exactlyhow the horizontal and vertical size have been set on a CRT. Youcan specify correct values either in the call to<code>windows</code> or as options: see <code>?windows</code>.(Typically these are of the order of 80.)</p><p>On one of our systems, the screen height is reported as 240mm,and the width as 300mm in 1280 x 1024 mode and 320mm in 1280 x 960and 1600 x 1200 modes. In fact it is a 21" monitor and 400mm x300mm! <a name="How%20do%20I%20more%20focus%20to%20a%20graphics%20window%20or%20the%20console%3f"></a></p><h2>4.4 How do I more focus to a graphics window or theconsole?</h2><p>You may want to do this from within a function, for example whencalling <code>idenitfy</code> or <code>readline</code>. Use thefunction <code>bringToTop()</code>. With its default argument itbrings the active graphics window to the top and gives it focus.With argument <code>-1</code> it brings the console to the top andgives it focus.</p><p>This works for <code>Rgui.exe</code> in MDI and SDI modes, andcan be used for graphics windows from <code>Rterm.exe</code>.</p><hr><a name="Workspaces"></a><h1>5 Workspaces</h1><a name="My%20workspace%20gets%20saved%20in%20a%20strange%20place.%20How%20do%20I%20stop%20this%3f"></a><h2>5.1 My workspace gets saved in a strange place: how do I stopthis?</h2><p>Have you changed the working directory?: see Q5.2. <a name="How%20do%20I%20store%20my%20workspace%20in%20a%20different%20place%3f"></a></p><h2>5.2 How do I store my workspace in a different place?</h2><p>Use the `File | Change Dir' menu item to select a new workingdirectory: this defaults to the last directory you loaded a filefrom. The workspace is saved in the working directory. You can alsosave a snapshot of the workspace from the `Save Workspace' menuitem.</p><p>From the command line you can change the working directory bythe function <code>setwd</code>: see its help page. <a name="Can%20I%20load%20workspaces%20saved%20under%20Unix%2fGNU-Linux%3f"></a></p><h2>5.3 Can I load workspaces saved under Unix/GNU-Linux?</h2><p>Yes. The converse (saving on Windows, loading on Unix) alsoworks on almost all Unix systems, and workspaces can beinterchanged with the Macintosh port too.</p><hr><a name="The%20R%20Console%20and%20Fonts"></a><h1>6 The R Console and Fonts</h1><a name="I%20would%20like%20to%20be%20able%20to%20use%20Japanese%20fonts"></a><h2>6.1 I would like to be able to use Japanese fonts</h2><p>for example, in the console and to annotate graphs.</p><p>We believe this is possible by setting suitable fonts in theRconsole and Rdevga configuration files (see Q4.2). You can specifyadditional fonts in Rdevga, and use them by</p><pre>par(font=, font.lab=, font.main=, font.sub=)</pre><p>Nineteen fonts are specified (as 1 to 19) by default: you canadd to these (up to 13 more) or replace them. <a name="I%20don't%20see%20characters%20with%20accents%20at%20the%20R%20console"></a></p><h2>6.2 I don't see characters with accents at the R console, forexample in ?text.</h2><p>You need to specify a font in Rconsole (see Q4.2) that supportsLatin1 encoding. The default, <code>Courier New</code>, does on oursystems, as does <code>FixedSys</code>. This may be a problem inother locales, especially for non-Western European languages. <aname="The%20output%20to%20the%20console%20seems%20to%20be%20delayed"></a></p><h2>6.3 When using Rgui the output to the console seems to bedelayed.</h2><p>This is deliberate: the console output is buffered andre-written in chunks to be less distracting. You can turn bufferingoff or on from the Misc menu or the right-click menu:<Ctrl-W> toggles the setting.</p><p>If you are sourcing R code or writing from a function, there isanother option. A call to the R function<code>flush.console()</code> will write out the buffer and soupdate the console. <a name="Long%20lines%20seem%20to%20be%20truncated."></a></p><h2>6.4 Long lines in the console or pager are truncated.</h2><p>They only <strong>seem</strong> to be truncated: that $ at theend indicates you can scroll the window to see the rest of themessage. Use the horizontal scrollbar or the <CTRL+arrow>keys to scroll horizontally.</p><hr><a name="Building%20from%20Source"></a><h1>7 Building from Source</h1><a name="How%20can%20I%20compile%20R%20from%20source%3f"></a><h2>7.1 How can I compile R from source?</h2><p>Get the R sources. Suppose you want to compile R-1.4.0. Start ina directory whose path does not contain spaces, and run</p><pre>tar zxvf R-1.4.0.tgzcd R-1.4.0cd src\gnuwin32</pre><p>Now read the <code>INSTALL</code> file and set up all the toolsneeded. Then you can just use <code>make</code>, sit back and wait.(A complete build takes about 15 minutes on a 300MHz PII with afast local disc.)</p><p>You may need to compile under a case-honouring file system: wefound that a <code>samba</code>-mounted file system (which maps allfile names to lower case) did not work. <a name="How%20do%20I%20include%20compiled%20C%20code%3f"></a></p><h2>7.2 How do I include compiled C code?</h2><p>We strongly encourage you to do this <em>via</em> building an Rpackage: see the <em>`Writing R Extensions'</em> manual. In anyevent you should install the parts of the R system for building Rpackages (in <code>SetupR.exe</code> or <code>rw1040sp.zip</code>),and get and install the tools (including Perl) and compilersmentioned in the file <code>readme.packages</code> containedtherein. Then you can use</p><pre>...\bin\Rcmd SHLIB foo.c bar.c</pre><p>to make <code>foo.dll</code>. Use <code>...\bin\Rcmd SHLIB--help</code> for further options, or see <code>?SHLIB</code>.</p><p>If you want to use Visual C++, Borland C++ or other compilers,see the appropriate section in <code>readme.packages</code>. <aname="How%20do%20I%20debug%20code%20that%20I%20have%20compiled%20and%20dyn.load-ed%3f"></a></p><h2>7.3 How do I debug code that I have compiled anddyn.load-ed?</h2><p>First, build a version of the R system with debugginginformation by</p><pre>make cleanmake DEBUG=T</pre><p>and make a debug version of your package by</p><pre>make pkgclean-mypkgmake DEBUG=T pkg-mypkg</pre><p>Then you can debug by</p><pre>gdb /path/to/rw1040/bin/Rgui.exe</pre><p>However, note</p><ul><li>gdb will only be able to find the source code if we run in thelocation where the source was compiled(<code>rw1040/src/gnuwin32</code> for the main system,<code>rw1040/src/library/mypkg/src</code> for a package), unlesstold otherwise by the <code>directory</code> command. It is mostconvenient to set a list of code locations via<code>directory</code> commands in the file <code>.gdbinit</code>in the directory from which <code>gdb</code> is run.</li><li>It is only possible to set breakpoints in a DLL after the DLLhas been loaded. So a way to examine the function<code>tukeyline</code> in package <code>eda</code> might be<pre>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) continueRconsole> library(eda)(gdb) break tukeyline(gdb) clear R_ReadConsole(gdb) continue</pre><p>Fortran symbols need an underline appended.</p></li><li>Windows has little support for signals, so the usual idea ofrunning a program under a debugger and sending it a signal tointerrupt it and drop control back to the debugger does not workwith <code>mingw32</code> version of <code>gdb</code>. It doesoften work with the <code>cygwin</code> version.</li><li>We have seen examples in debugging problems with Windows eventsthat the <code>cygwin gdb</code> was able to catch but whichterminated the <code>mingw32 gdb</code>.</li></ul><p>If you have an X server available on the PC, there is a versionof <code>DDD</code> available that runs under the cygwin emulationlayer (follow the links at <a href="http://www.cygwin.com">http://www.cygwin.com</a>) and provides agraphical user interface to <code>gdb</code>. Another(Windows-native) GUI for <code>gdb</code> is <code>Insight</code>,part of the latest <code>cygwin</code> version of <code>gdb</code>.<a name="How%20do%20I%20include%20C++%20code%3f"></a></p><h2>7.4 How do I include C++ code?</h2><p>You need to do two things:</p><p>(a) Write a wrapper to export the symbols you want to call fromR as <code>extern "C"</code>.</p><p>(b) Include the C++ libraries in the link to make the DLL.Suppose <code>X.cc</code> contains your C++ code, and<code>X_main.cc</code> is the wrapper, as in the example in<em>`Writing R Extensions'</em>. Then build the DLL by(<code>gcc</code>)</p><pre>...\bin\Rcmd SHLIB X.cc X_main.cc</pre><p>or (VC++, which requires extension <code>.cpp</code>)</p><pre>cl /MT /c X.cpp X_main.cpplink /dll /out:X.dll /export:X_main X.obj X_main.obj</pre><p>or (Borland C++, which also requires extension<code>.cpp</code>)</p><pre>bcc32 -u- -WDE X.cpp X_main.cpp</pre><p>and call the entry point(s) in <code>X_R</code>, such as<code>X_main</code>. Construction of static variables will occurwhen the DLL is loaded, and destruction when the DLL is unloaded,usually when R terminates.</p><p>Note that you will not see the messages from this example in theGUI console: see the next section.</p><p>This example is in package <code>cxx_0.0-x.tar.gz</code> in the<code>src/contrib/Devel</code> section on CRAN, and that can becompiled as a package in the usual way on Windows. <a name="The%20output%20from%20my%20C%20code%20disappears."></a></p><h2>7.5 The output from my C code disappears. Why?</h2><p>The <code>Rgui.exe</code> console is a Windows application:writing to <code>stdout</code> or <code>stderr</code> will notproduce output in the console. (This will work with<code>Rterm.exe</code>.) Use <code>Rprintf</code> or<code>REprintf</code> instead. These are declared in header file<code>R_ext/PrtUtil.h</code>.</p><p>Note that output from the console is delayed (see <a href="#The%20output%20to%20the%20console%20seems%20to%20be%20delayed">Theoutput to the console seems to be delayed</a>), so that you willnot normally see any output before returning to the R prompt. <aname="The%20output%20from%20my%20Fortran%20code%20disappears."></a></p><h2>7.6 The output from my Fortran code disappears. Why?</h2><p>Writing to Fortran output writes to a file, not the<code>Rgui</code> console. Use one of the subroutines<code>dblepr</code>, <code>intpr</code> or <code>realpr</code>documented in the <em>`Writing R Extensions'</em> manual. <a name="The%20console%20freezes%20when%20my%20compiled%20code%20is%20running"></a></p><h2>7.7 The console freezes when my compiled code is running.</h2><p>The console, pagers and graphics window all run in the samethread as the R engine. To allow the console etc to respond toWindows events, call <code>R_ProcessEvents()</code> periodicallyfrom your compiled code. If you want output to be updated on theconsole, call <code>R_FlushConsole()</code> and then<code>R_ProcessEvents()</code>. <a name="The%20Perl%20scripts%20don't%20seem%20to%20work%20under%20Windows%209x%2fME"></a></p><h2>7.8 The Perl scripts don't seem to work under Windows9x/ME</h2><p>This has been seen under some versions of Perl and Windowsversion (95/98/ME) which use a 16-bit shell. Hopefully this version(rw1030) is more robust in this respect: it <em>may</em> help toupgrade your Perl version (5.6.1, build 626 was current at the timeof writing).</p><hr width="100%"><address>Last edited 2001 June 21 by Professor B. D. Ripley<code><a href="mailto:ripley@stats.ox.ac.uk">ripley@stats.ox.ac.uk</a></code></address></body></html>