Rev 17167 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<html lang="en"><head><title>R for Macintosh DOC/FAQ</title></head><body><h1 align="center">R for Macintosh FAQ/DOC</h1><h2>Version for <tt>R 1.4.0</tt></h2><address>S. M. Iacus</address><p>Changes and bug fixing specific to this version:<ul><li> Added the Preferences pane. The settings in .Renvironare now superseeded by the prefences settings.Renviron can be still used to simulate the Environmentfor the Sys.getenv() call.</li><li> Added the item "Link Packages Help" to the "Help" menu.</li><li> Fixed a bug that set the help menu items ghosted afterhaving used them.</li><li> Some MRC Apple's Compiler specific fixing.</li><li> Fixed problems with current working directory in differentpoints (.Rprofile, .Renviron, etc).</li><li> Solved the problem of line endings that are different fromMacOS and OS X. Now text files generated under both systemsare fine to R.</li><li> Makefiles and perl scripts have been fixed so that now Rbuilds via MPW shell scripts and help files are generatedas well.</li><li> A bug in the internal file viewer that suppressed the "_"symbols from the text has been fixed.</li><li> This version of R is slower at startup but faster thanthen previous release (by a factor of 10%) in calculations.</li><li> The initial window at startup has been suppressed in thisreleasein the hope to provide am applescript analogous to passinitial arguments to R. Anyway this option was mostly disturbingR users then used by them.</li><li> The about box now reports informations on the currentrelease of R</li><li> Added the zlib capability so now R can manage gzipped files andconnections</li><li> Fixed some wrong links in html help files</li><li> Finally fixed copy and paste of graphic windows contentsand saving of them onto files. For some reason the previousalgorithm did not copy text characters under MacOS X.</li><li> Fixed a bug that appear when trying to reading files ordirectories on a different volume w.r.t. the currentworking directory of R.</li><li> Added two functions file.edit() and new.file().The file.edit() function is similar to file.show() butlet the user edit the opened file. It it the equivalentto the menu command "OPen File for Editing..." whilenew.file() is the equivalent to the "New Window" menucommand with the difference that you can specify thename of the new file to edit. For more details seeman pages.</li><li> Added three functions to manipulate a User menu in theR Console menubar. With add.menu.cmd(label,command) theuser can add menu item "label" to which is associatedan R command. Respectively with del.menu.cmd(label) andget.menu.cmd(label) the user can remove or get thecommand associated to the menu "label". See the helppages for details and examples.</li><li>Added three functions to manipulate a User menu in theR Console menubar. With del.usr.cmd() the whole usermenu is removed. Respectively with del.num.cmd(menunum)and get.num.cmd(menunum) the user can remove or get thecommand associated to the menu numbered "menunum". Seethe help pages for details and examples.</li><li>Fixed some problems with windows naming (duplicates and so forth)</li><li>Windows (both text and graphic) now appears only afterrepositioning</li><li><li> lwd parameter in graphic functions re-implemented evenif not yet perfectly working.</li><li> lty & lwd paramter now works for all the graphic callapart for Circle.</li><li> Fixed a bug in the function edit(). Now it behavescorrectly. If you call it without parameters, thelast temporary edited file will be shown. See manpages of edit(). Consequently it is now fixed theproblem with the function fix().</li><li>Refresh of graphic windows fixed. One time only andthe bottom part of the window is correctly redrawn.</li></ul><p><p><hr><p><!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>rmac-FAQ.html</title></head><body><center>This is the ReadMe file of R for Macintosh Application.<p>We discuss here the following topics:</center><p>* <a href="#NEWS">NEWS</a><br>* <a href="#GUI">THE GUI</a><br>* <a href="#SCRIPTS">APPLE SCRIPT SUPPORT</a><br>* <a href="#EDITOR">EXTERNAL EDITOR INTERACTION</a><br>* <a href="#MEMORY">MEMORY</a><br>* <a href="#PREFERENCES">SPECIFYING OPTIONS: the Preferences pane</a><br>* <a href="#OPTIONS">SPECIFYING ENVIRONMENT VARIABLES: the .Renviron file</a><br>* <a href="#USERMENU">THE USER MENU</a><br>* <a href="#HELPERS">R HELPERS</a><br>* <a href="#REQUIREMENTS">SYSTEM REQUIREMENTS</a><br>* <a href="#KBUGS">KNOWN BUGS</a><br>* <a href="#FAQ">SHORT FAQ (in the MAC-FAQ)</a><br>* <a href="#REMERC">REMERCIEMENTES</a><p><hr WIDTH="100%"><p><a NAME="NEWS"></a><b>NEWS</b><br>There are several enanchements in this release. Most of them concernthe user interface of R application but one of the most important noveltyis that now<br>R runs both on MacOS and MacOS X using Carbon technology. This meansthat when you run R from MacOS X it run natively under the new System withoutcalling the Classic Compatibility Module. The use of R under MacOS X takeslots of advantages starting from the new Aqua look.<p>As this version is based on the new Carbon technology some new bugscan appear that we were'nt able to found before releasing R officially.<p>Any feedback is then welcome at stefano.iacus@unimi.it<br><br><p><a NAME="GUI"></a><b>THE NEW GUI</b><br>Several menus are now present from this release. The structure of themenus is as follows with a brief description.<table BORDER=1 CELLSPACING=3 CELLPADDING=3><tr><td>Menu </td><td>Item</td><td>Shortcut</td><td>Brief description</td></tr><tr><td>Apple (or Application Menu under MacOS X)</td><td></td><td></td><td></td></tr><tr><td></td><td>About R </td><td> </td><td>Opens the R information dialog. Reports release informations.</td></tr><tr><td></td><td>Preferences </td><td>(under OS X only, see the Config menu for pre X Systems)</td><td>Opens the R Preferences pane</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>File</td><td></td><td></td><td></td></tr><tr><td></td><td>New Edit Window </td><td>N </td><td>Opens an empty editable window. You can usethis as an internal editorfor R. If the current active window isa graphic device window than a newmacintosh() device will be opened.</td></tr><tr><td> </td><td>Edit Object</td><td> E </td><td>Is the equivalent of "edit(object)"</td></tr><tr><td></td><td>Source File</td><td> O</td><td>Opens a file and sources it. This is equivalent to "source(file)"</td></tr><tr><td></td><td>Open File For Editing</td><td> </td><td>Opens a file in an editable window.Useful when you want to modify anexisting script and test it.</td></tr><tr><td></td><td>File Show </td><td>F</td><td>Open a file in a non editable window. This isthe equivalent ofR command "show.file(file)"</td></tr><tr><td></td><td>Load Workspace File</td><td>L </td><td>If you want to load a wspace image otherthan ".RData"</td></tr><tr><td> </td><td>Save Workspace As</td><td></td><td>If you want to save an image file other the ".RData"</td></tr><tr><td></td><td>Page Setup</td><td></td><td> Calls the printer driver page setup</td></tr><tr><td></td><td>Print </td><td> P</td><td>Print the text window (R Console etc) or the imagein the graphic devicewindow. The image is rescaled to the page dimension of yourprinter.</td></tr><tr><td></td><td>Save</td><td> S</td><td>Save the window. This could be the content ofthe R Console i.e. yourcurrent R session any text window or the graphic device window. </td></tr><tr><td></td><td>Save As...</td><td> </td><td>Save the window. This could be the content ofthe R Console i.e. yourcurrent R session any text window or the graphicdevice window. This menuacts as a standard "Save As" menu so you have to specify each time thefilename.</td></tr><tr><td></td><td>Close </td><td> W </td><td>Closes the current window. If it is the R Consolewindow than it is interpreted as quitting R.</td></tr><tr><td></td><td>Quit</td><td> Q</td><td>This menu item is on the Application Menu under MacOS X</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>Edit</td><td></td><td></td><td></td></tr><tr><td></td><td>Undo</td><td> Z</td><td></td></tr><tr><td></td><td>Cut</td><td> X</td><td></td></tr><tr><td></td><td>Copy</td><td> C </td><td>If you use it on a graphic device window theimage is copied to theclipboard (see also knownbugs)</td></tr><tr><td></td><td>Paste </td><td>V</td><td></td></tr><tr><td></td><td>Copy & Paste</td><td> </td><td>You copy some text and the resultis pasted into the R Consolewindow. You use thiswhen you select a piece ofR code of text windowand then you want to R to execute it. This isquite useful when you want to test part of your scriptof the examples of an help window</td></tr><tr><td> </td><td>Clear</td><td></td><td></td></tr><tr><td></td><td>Select All</td><td> A</td><td></td></tr><tr><td></td><td>Goto line</td><td></td><td> Active only for editable windows. It moves thecursor toa certain line</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>Tools</td><td></td><td></td><td></td></tr><tr><td></td><td>Show Workspace</td><td></td><td> It is equivalent to "ls()"</td></tr><tr><td> </td><td>Clear Workspace</td><td></td><td> It is equivalent to "rm(list=ls())"</td></tr><tr><td></td><td>Load Workspace</td><td></td><td> Loads the ".RData" file; equivalent toload(".RData")</td></tr><tr><td></td><td>Save Workspace</td><td></td><td> Save the workspace to ".RData"; equivalent to "save.image()"</td></tr><tr><td></td><td>Load History</td><td></td><td> It is equivalent to "loadhistory()"</td></tr><tr><td></td><td>Save History </td><td></td><td>It is equivalent to "savehistory()"</td></tr><tr><td></td><td>Show History </td><td></td><td>It is equivalent to "history()"</td></tr><tr><td></td><td>Change Working Directory</td><td>D </td><td>Allows the user to change the workingdirectory by using a standarddialog</td></tr><tr><td></td><td>Show Working Directory</td><td></td><td> It is equivalent to "getwd()"</td></tr><tr><td></td><td>Reset Working Directory </td><td></td><td>It is equivalent to "setwd(R.home())"</td></tr><tr><td></td><td>Show Libraries </td><td></td><td>It is equivalent to "library()"</td></tr><tr><td> </td><td>Show DataSets </td><td></td><td> It is equivalent to "data()"</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>Windows</td><td></td><td></td><td></td></tr><tr><td></td><td>R Console</td><td></td><td> This menu contains by default only the "R Console" itemand it is dynamically changed by appending/removing thenames of any new/closed window</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>Config</td><td></td><td></td><td></td></tr><tr><td></td><td>Allow Interrupt</td><td> </td><td>It is equivalent to set the option "Interrupt=TRUE" in the.Renvironment config file but this can be changed at runtime.This menu is syncronizedwith the option you select in the Preference pane.</td></td></tr><tr><td> </td><td>On Open Source</td><td></td><td>It is equivalent to set the option "OnOpenSource=TRUE" in the.Renvironment config file but this can be changed at runtime. Useful towork with external editor such as Alpha. This menu is syncronizedwith the option you select in the Preference pane.</td></tr><tr><td></td><td>Preferences </td><td>(under Mac OS only)</td><td>Opens the R Preferences pane</td></tr><tr><td>Help</td><td></td><td></td><td></td></tr><tr><td></td><td>R Help</td><td>? </td><td> It is equivalent to "help.start()"</td></tr><tr><td> </td><td>Help On Topic</td><td></td><td> Opens a dialog where the user can specify an item he orshe wants to see. equivalent to "help(topic)" or"?topic"</td></tr><tr><td></td><td>Search Help On </td><td></td><td> Opens a dialog where the user can specify an argument tohave help on. It is equivalent to"help.search("topic")"</td></tr><tr><td> </td><td>Run An Example </td><td></td><td>Opens a dialog where the user can specify an item of which he or shewants to run anexample of. It is equivalentto "example(topic)".</td></tr><tr><td> </td><td>Link Packages Help</td><td></td><td>After installing a new package you need to link help files database.</td></tr></table><i><u></u></i><p><i><u>About R windows.</u></i><br>Normally R opens windows to let 80 character/columns to be displayed.The size of the windows is calculated on the basis of the size of the fontused.<br>For non fixed fonts the algorithm can fail so the window can resulta bit larger or smaller then needed.<br>R windows are opened in cascade for each class (edit windows, fileshow windows and graphic windows). This functionality does not work onMacOS X yet.<br><p><a NAME="SCRIPTS"></a><b>APPLE SCRIPT SUPPORT</b><br>From release 1.3.1 R has partial support for AppleScripts.This means two things: you can run applescripts from inside R using thecommand applescript() (see the corresponing help) or you can ask R to runcommands <b>from</b> and applescript. The directory "scripts" in the mainR folder contains two examples of applescripts. What follows is an example ofapplescript that interacts with R.<p><BLOCKQUOTE><b>set</b> CommandLine to "R.Version()"<br><b>try</b><br><b>tell</b> application "R"<br> <b>activate</b></b><br> with <b>timeout</b> of 90000 seconds<br> <b>cmd</b> CommandLine<br> <b>cmd</b> "Sys.getenv()"<br> <b>end</b> timeout<br> <b>end</b> tell<br><b>end</b> try<br></BLOCKQUOTE><p>Where <b>cmd</b> is the applescript command in the R dictionary that isused to tell R to execute an Rcommand in the R Console. The syntax is <b>cmd</b> <<i>commandstring</i>>, where <i>command string</i> have to be in quotes.Actually, the output of the command is not sent back to theapplication that is calling R but to the RConsole.<p><a NAME="EDITOR"></a><b>EXTERNAL EDITOR INTERACTION</b><br>From release 7.4.1 of the famous Alpha editor, there is a (tcl) modecalled S+/R.<br>When you open a file in Alpha with the extension ".s" or".r" this new mode will be installed and you will in the Alpha menubar the "S+/R" menu. Of this menu you can use "Process File" or "ProcessSelection" to interact with R. By default Alpha sends an open commandto R and by default R opens a file in a non editable window (equivalentto the File Show menu). If you want R to source a file you should modifyactivate the option "OnOpenSource" thatis set by default to "FALSE". You can changethis at runtime running via the Config/OnOpenSource menu or accessingthe Preferences pane.The latest version of Alpha can be found at<a href="http://alpha.olm.net/">http://alpha.olm.net</a><a href="http://www.alpha.olm.net"></a><p><a NAME="MEMORY"></a><b>MEMORY</b><br>Under MacOS you should reserve a fixed amount of memory to each application.As R is just an application, you need to set this to a bigger amount ofmemory if for some reason R went out of memory. To do this, go to the Finderand select the R aplication icon. Then with CMD+I key obtain the Informationfor R. Select "Memory" and the fix the amount of memory you need. UnderMacOS X, there is no need to reserve memory to R. R will use as muchmemory as it needs.<p><a NAME="PREFERENCES"></a><br><b>SPECIFYING OPTIONS:</b> the Preferences pane<br>The Preferences pane allow you to configure a bit R GUI and behaviour.You can set the tab size in your edit windows, the font type and size oftext windows and R Console as well as the colors of the text in R Console.You can also specify a particular font for the graphic device and theresolution of the graphic device. Finally you can specify if R shouldaccept User breaks (CMD+. or Esc). If this option is enabled R is a bitslower. You can instruct R on what to do when a file is opened: source itor simply show in the internal viewer.<p>Take care that under MacOS R creates a file in the Preferences folder ofyou System Folder. If you switch to MacOS X than, this folder is no longerthe default Preferences folder so you have either to move th "Rpreferences" file to "~user/Library/Preferences/" directory or reset thepreferences.If you have different logins under OS X, remember that each user should set its ownpreferences.<br><p><a NAME="OPTIONS"></a><br><b>SPECIFYING ENVIRONMENT VARIABLES: </b>the .Renviron file<br>In this file you can specify some of options or environment variables. This is not standardfor general MacOS/X applications but has been implemented forcompatibility reasons. If you don't need to set environment variables youcan ignore what is in this file.<br>The environment file is used by R application both to simulate theenviroment on a standard Unix or Windows system.<br>You can always use "Sys.getenv()" to see which variables are set tosome values.<br> The .Renviron file looks like this:an option is a "Rkey" with its "keyvalue" that you can specify in new separateline as follows RKey=keyvalue. Consider that RKey=keyvalue and RKey= keyvalue are different, that means that blanks/spaces are significant."RKey" and "keyvalue" are case sensitive. A symbol "#" at the beginningof a line means that this is a commented out line.<br>You can find more details on that in the .Renviron file itself.<p><a NAME="USERMENU"></a><br><b>THE NEW USER MENU</b><br>The user has now the ability to create a menu with several menuitems,up to 99, where to keep preferred R commands. <br>With the commands add.menu.cmd("label","R_command") the user adds a menuitem named "label" to theUser menu. When the command is selected from the menu, R executes the command "Rcommand"associated to it.The User menu is created dynamically, so that user will never see it if he does not add anyitem to it.<br>Several functions to manipulate the user menu are previewed: <p><table border = 2><tr><td>get.menu.cmd("label")</td><td>returns the R Command associated to menu item "label" and the corresponding menu number</td></tr><tr><td>get.num.cmd(menunum)</td><td>returns the R Command associated to menu item number "menunum" and the corresponding menu label</td></tr><tr><td>del.menu.cmd("label")</td><td>removes the menu item "label" from the User menu</td></tr><tr><td>del.num.cmd(menunum)</td><td>removes the menu item numbered "menunum" from the User menu</td></tr><tr><td>del.usr.cmd("label")</td><td>removes the whole User's menu</td></tr><tr><td>add.menu.cmd("label","RCommand")</td><td>adds a menu item to the User's menu, if any, with associated the R command "RCommand"</td></tr></table><p><a NAME="HELPERS"></a><b>R HELPERS</b><br>* If you want to use an external editor we suggest you to use Alphaversion 7.4.1 or newer that contains a S+/R mode. Alpha home pageis<br><a href=" http://alpha.olm.net/"> http://alpha.olm.net</a><br>* You also need MacZip to use the unzip feature of R. MacZip home pageis<br> <a href="http://www.sitec.net/maczip">http://www.sitec.net/maczip</a><br><br><p><a NAME="REQUIREMENTS"></a><b>SYSTEM REQUIREMENTS</b><p>To run the R application you need at least 42MB of free memory for theapplication itself you work under MacOS but there is no limitations underMacOS X as virtual memory is always on.<br>You need the latest version of the<a href="http://asu.info.apple.com/swupdates.nsf/artnum/n11916">CarbonLiblibrary</a> from Apple. At the time of this release, version 1.4 is the current non developer release.Normally it is included in System 9.2 and X.<br><a NAME="f2cLib">Now R needs the f2cLib shared library to run. Thislibrary is distributed with R but in case you miss it you can found it <ahref="http://www.ci.tuwien.ac.at/~iacus/R">here</a>.<br>The minimum System version release is 8.6 (+ CarbonLib library).<br>You need the WasteLib library. This library is distributed with Rbinaries.<br>You need the zlibLib library. This library is distributed with Rbinaries.<p><br><a NAME="KBUGS"></a><b>KNOWN BUGS</b><br><ul><li>In some situations R stops execution giving an error like this:</li></ul>Error in plot.xy(xy.coords(x, y), type = type, pch = pch, col = col, bg= bg, :<br>negative length vectors are not allowed<br>To solve this problem you just need to resize the device window to abigger size with your mouse and resubmit the graphic command in R.<br><ul><li>For some reason MacZip does not intercat too much with R under MacOSX. Moreover MacZip has not yet been carbonized so when R callsit to uncompress items it also starts up Classic Environment. Wesuggest to uncompress the help and examples files directly by usingStuffit Expander that is part of the utilities provided with SystemX.</li><li> This version of R and Adobe ATM are incompatible. We are looking atthe problem. The solution is that you should switch ATM off before runningR. (Thanks to R. Gill for feedback on this bug)</li><li>Internet functionality is not available yet. We are working on this.</li><li>Mathematical expressions are not yet well spaced moreover,mathemathic symbols are not rotated.</li></ul><a NAME="FAQ"></a><b>SHORT FAQ (in the MAC-FAQ)</b><br><br><table BORDER COLS=2 WIDTH="100%" ><tr><td>Q</td><td>How can I manage invisible files under MacOS X ?</td></tr><tr><td>A</td><td>Under Unix it is typical that invisible files are files starting witha "." (dot) in the filename. MacOS X conforms to this convention. So itcould happen that your preferred editor doesn't allow you to open and orwrite files like .Rprofile or .Renviron under MacOS X (this is the case ofBBedit as reported by one user). You have to options. Edit a filelike "some_file" with your editor or R, and then go to the shell (that isthe Term application) and change the name in ".some_file" using thecommand "mv some_file .some_file".The second option is to edit the file directory with a unix editor like"emacs". Again from the shell simply use "emacs .some_file", edit it andsave it (ctrl+x, ctrl+s) then exit (ctrl+x, ctrl+c).You will no longer see this file fromthe shell unless you use commands like "ll".</td></tr><tr><td>Q</td><td>On exit: Why I can't save the workspace image via file dialog under MacOS X ?</td></tr><tr><td>A</td><td>As before, files starting with a dot, such as ".RData" cannot be manageddirectly via standard dialogs (you can see invisible files butyou can't specify them as filenames !)<br>To save the workspace image, youcan either save it with a different name (e.g. "RData", but in thisthe workspace image will not be reloaded the next you start R), or yousave it beofre quitting R:type "save.image()" from the R Console and then "q()" replying "n"when R asks for "Save workspace image? [y/n/c]:".</td></tr><tr><td>Q</td><td>How can I work on a separate directory for each of my projects?</td></tr><tr><td>A</td><td>Under Unix you usually create a directory, go into it and launch R.Under MacOS you can create a directory and put all the files that you needthere. You then (or before) run R in its own directory and use themenu item "Tools->Change Working Directory" to change the currentworking directory to directory you have created. You can then workas you do in Unix. You can save/load workspace image to this directory,as well as the command history files. You can then reload these nexttime you work.</td></tr><tr><td>Q</td><td> How can I interrupt lengthy operations or output ?</td></tr><tr><td>A</td><td> You can now use the standard Macintosh control break sequence,that is you should press "Cmd option" and "." (dot). This will interruptany R loops. The "Esc" key gives you the same result.</td></tr><tr><td>Q</td><td> How can I change memory settings for R ? (MacOS pre X only)</td></tr><tr><td>A</td><td> You cannot use the standard settings as on other platforms. Youshould assign memory to R from the Finder/Information dialog forR application. See Section "Memory" above.</td></tr><tr><td>Q</td><td> When I use to send R output to a file like "my_file", R seems to work on this file butI cannot find it. What happened ? (MacOS X only)</td></tr><tr><td>A</td><td> On MacOS X it is important to specify correctly the file names. If youwant the file to be created in your current working directory you have toput a ":" before file name, such as ":myfile" otherwise the file will be createdas "/my_file", i.e. in the root "/" directory. This is in particularimportant when you specify directories relative to your current workingdirectory.</td></tr></table><p><a NAME="REMERC"></a><b>REMERCIEMENTS</b><br>I would like to thank among the others (only few I can remember due to my brain volatility...) some of the peoplewho have contantly sent mefeedback on this Macintosh port of R or simply suggetested me some possibiledirections. So, <i>merci</i>, in random order, to P. Macdonald, P. Flint, R. Gill, K. Pflugshaupt,J. DeLeeuw, G. Sawitzki and half of the R-Core.<p><hr WIDTH="100%"><address>Last edited 2001 December 4th, Stefano M. Iacus<code><ahref="mailto:stefano.iacus@unimi.it">stefano.iacus@unimi.it</a></code></address></body></html>