R Studio For Mac

Frequently Asked Questions on R for Mac OS X

  1. R-studio For Mac Serial
  2. R Studio For Mac 10.10.5

Version 3.5.0 2018-04-23, R.app 1.71

R-Studio for Mac is a comprehensive application to restore data from HFS/HFS+ file systems. The data recovery software is capable of restoring data on disks, even if they are partially damaged, deleted, or formatted. Other posts addressing similar issues provide solutions to Linux (with the apt-get command, etc) but doesn't seem to have a Mac solution. Highly appreciate if someone with insight can offer some guide here. R-Studio for Mac run in the demo mode allows you to evaluate how the utility recovers lost files. The only limitation is you can not recover files larger than 256KB in the demo mode. R-Studio for Mac is registered on on-the-fly and no reinstallation required.

Stefano M. IacusSimon UrbanekRob J. GoedmanBrian Ripley

Daily Build (desktop-mac) Note: The following builds are intended for development and testing purposes, and are not recommended for general use. For stable builds.

• Introduction:
• R.app:
• How to install packages:
• R and external applications:
• Quartz device:
• Tcl/Tk issues:
• Internationalization of the R.app:
• Additional resources:
• Acknowledgments:
• Miscellaneous questions:
• How many versions of R for Mac OS X?:
• What machines does R for Mac OS X run on?:
• How can R for Mac OS X be obtained and installed?:
• How to get R.app:
• How to install the R.app:
• The R Console:
• General Features:
• The Menus:
• Preferences:
• R.app Bugs:
• The Input and the Output:
• Copy and Paste:
• The current and startup working directories:
• Resizing the R Console:
• R Console text colors:
• Editor:
• Editor undo and line numbers:
• Editor text completion:
• Editor function list:
• Editor syntax coloring:
• Editor (internal and external):
• Editor help:
• Drag & drop:
• Help system:
• History:
• Authentication and .libPaths:
• Application Menu:
• File Menu:
• Edit Menu:
• Misc Menu:
• Workspace Menu:
• Packages Menu:
• The Help Menu:
• Startup:
• Editor Preferences:
• Syntax Colors:
• Console Colors:
• Quartz window:
• Which kind of packages can I install using the GUI?:
• Installation of packages:
• Installation of source packages:
• Where are the packages I've installed?:
• AppleScript support:
• External editors:
• Finder actions:
• Interactive mode:
• Saving the image:
• Copying the image into the clipboard:
• Apple Developer Connection:
• The R for Mac OS X Developer page:
• How can I have a per session .Rprofile?:
• What happens if I drag a file on the R icon?:
• How can I interrupt lengthy operations or output?:
• I see spurious error messages when starting R!:
• Which BLAS is used and how can it be changed?:
• I don't see a thing when installing packages!:
• Why are there faint lines in image plots?:
• Why doesn't R GUI support keyboard shortcut XYZ ?:
• What is the difference between the CRAN build and a vanilla build?:
• Why is R.home() not versioned?:
• R.app GUI crashes on startup!:
• Why is the GUI not saving my history?:
• I get ``command not found' in the GUI yet it works in the Terminal -- why?:
• I see no text in a Quartz plot!:
• I get ``clang: error: unsupported option -fopenmp' when compiling a package -- why?:

Next: R.app, Previous: Top, Up: Top

1 Introduction

This document contains a user guide to the R.APP version of R, andinformation on using R on OS X which supplements the main Rmanuals. As from R 3.0.0 most of the information has been moved tothose manuals, the latest versions of which can be found athttp://cran.r-project.org/manuals.html.

In this document R refers to the core, command-line-based R systemwhile R.APP refers to the GUI-based Mac OS application that controlsthe underlying R.

This ‘R for Mac OS X FAQ’ is rather incomplete at the moment and requirescontributions from users. Anything specific to the R language can befound in the main R-FAQ (seehttp://cran.r-project.org/doc/FAQ/R-FAQ.html). Please send anyrequests/questions you would like answers to theR-SIG-Macmailing list (after subscribing) as well as comments on this FAQ.

The last section of this document contains the most frequently askedquestions that don’t fit strictly into any of the categories above – itis usually a good idea to always look into that section if your issuedoesn’t fit any of the above or was not answered in one of the specificsections. Always read this FAQ before asking for help onR-SIG-Mac!

• How many versions of R for Mac OS X?:
• What machines does R for Mac OS X run on?:
• How can R for Mac OS X be obtained and installed?:

Next: What machines does R for Mac OS X run on?, Previous: Introduction, Up: Introduction

1.1 How many versions of R for Mac OS X?

There is only one version of R for Mac OS X. However, R on Mac OS Xcan be used either on the command-line as on other Unix systems, or viathe R.APP GUI (see R.app). The second approach is mostlypreferred by Macintosh users.

Prior to R 3.0.0 there were separate 32- and 64-bit version ofR.APP: nowadays only 64-bit builds are supported in binary form.

Next: How can R for Mac OS X be obtained and installed?, Previous: How many versions of R for Mac OS X?, Up: Introduction

1.2 What machines does R for Mac OS X run on?

64-bit Intel-based Macs, that is any machine made since mid 2008.

Previous: What machines does R for Mac OS X run on?, Up: Introduction

1.3 How can R for Mac OS X be obtained and installed?

R is available on CRAN in the form of an Installer packagecontaining the R framework and the R.APP GUI. The package is usuallynamed R.pkg with an optional version number.

The installation is done by double-clicking on the Installerpackage. The Installer will guide you through the necessary steps. Notethat it will require password or login of an account with administratorprivileges. The installation can be customized, but the default issuitable for most users.

Snapshots of the R-patched and R-devel flavours are available athttp://r.research.att.com/, packaged in the same way.

Further details, including uninstallation and building R from thesources, are in the ‘R Installation and Administration Manual’.

Next: How to install packages, Previous: Introduction, Up: Top

2 R.app

• How to get R.app:
• How to install the R.app:
• The R Console:
• General Features:
• The Menus:
• Preferences:
• R.app Bugs:

R.APP is the name of the GUI for Mac OS X that was introduced in R2.0.0. It appears as an icon labeled R, but to avoid confusionwith general R, we prefer to use the name as it appears when usingGet Info on the GUI: R.APP This stands for Rapplication.

Internally R.APP is a Cocoa program (hence written in Objective C)which links to embedded R installed as a framework.

Next: How to install the R.app, Previous: R.app, Up: R.app

2.1 How to get R.app

R.APP is part of the binary distribution of R for Mac OS X availablefrom CRAN. That distribution consists of one package containing the Rframework and R.APP.

Development versions of R.APP are made available on daily basis in theform of a disk image containing the R.APP itself. See the Mac OS Xpages on CRAN for detail how to obtain such snapshots (currently athttp://R.research.att.com/).

Next: The R Console, Previous: How to get R.app, Up: R.app

2.2 How to install the R.app

R.APP is installed the same way as the R framework, namely usingbinary package provided on CRAN. The bin/macosx directory of aCRAN site contains a standard Apple installer package namedR.pkg (optionally containing the version number). Download anddouble-click the package icon.

Please, carefully read the note on the usage of tcltk and Fortran on the bin/macosx directory of a CRAN site.

Next: General Features, Previous: How to install the R.app, Up: R.app

2.3 The R Console

In this section you’ll find general information on the R.APP. For specific R tasks thatcan be done via the R.APP using menus you should read below (see The Menus).

• The Input and the Output:
• Copy and Paste:
• The current and startup working directories:
• Resizing the R Console:
• R Console text colors:

Next: Copy and Paste, Previous: The R Console, Up: The R Console

2.3.1 The Input and the Output

The current design of the R Console is to have a single frame for input (user) and output (R).

Next: The current and startup working directories, Previous: The Input and the Output, Up: The R Console

2.3.2 Copy and Paste

Copy and paste works in R as in any other Macintosh application.

If you want high resolution graphic exports, you can save the PDF format using the File/Save as menu item (see Quartz device). Or you can use supported formats in R through pdf(), jpeg() etc. (type ?capabilities to get more details).

Next: Resizing the R Console, Previous: Copy and Paste, Up: The R Console

2.3.3 The current and startup working directories

If not otherwise specified in the Preferences (see Preferences), or if the specified path is no longer available, then the default working directory at startup is the user home.The working directory can be changed using the setwd R command or using the Misc menu item Change working directory. Finally it is possible to use a specific directory for a single R session by dragging a folder onto the R.APP icon. If R.APP is not running, this will cause R.APP to be started in the directory corresponding to the folder dragged. The same can be achieved on the command line – for example open -a R . causes R.APP to be started using the current directory as the startup working directory.

This feature is useful if you want different startup procedures defined by the .Rprofile; you can edit a .Rprofile (containing you personal initialization R commands) in a particular directory and usethe Preferences (or any other method mentioned above) to change the startup directory. Next time you launch R.app the .Rprofile is read and executed by R at startup. This is the equivalent on Unix (or the command line) to launch R from different directories.

Next: R Console text colors, Previous: The current and startup working directories, Up: The R Console

2.3.4 Resizing the R Console

When the R Console Window is resized, the R option width is set appropriately so that any futureoutput will fit the window size.

Previous: Resizing the R Console, Up: The R Console

2.3.5 R Console text colors

Use the Preferences window to set the R Console text colors (see Preferences).

Next: The Menus, Previous: The R Console, Up: R.app

2.4 General Features

• Editor:
• Editor undo and line numbers:
• Editor text completion:
• Editor function list:
• Editor syntax coloring:
• Editor (internal and external):
• Editor help:
• Drag & drop:
• Help system:
• History:
• Authentication and .libPaths:

Next: Editor undo and line numbers, Previous: General Features, Up: General Features

2.4.1 Editor

R.APP provides an integrated editor for editing of R code. It sports a number of features designed to help developing code inside R. The probably most often used function is the ability to execute code directly from the editor by pressing Command-Return. Other features include syntax highlighting, brace-matching, code completion and function indexing.

Next: Editor text completion, Previous: Editor, Up: General Features

2.4.2 Editor undo and line numbers

The editor supports undo/redo operations on an appropriate level of granularity (used tobe all or nothing). The editor has an optional facility to show line numbers. These help withlocating error messages. The editor also responds to the ’Go to Line’ Edit menu function. Theassociated Preference Pane allows enabling/disabling of the line numbers, as well as setting linenumber gutter width (to fit larger line numbers) and text margin width.

Next: Editor function list, Previous: Editor undo and line numbers, Up: General Features

2.4.3 Editor text completion

Completion of typed input (both file names and R code) in the editor is available through the Edit menu ’Complete’ or by typing Control-. (same as is Xcode). It uses the same facilities as the console window (for compatibility the console responds to both Tab and Control-.).

Next: Editor syntax coloring, Previous: Editor text completion, Up: General Features

2.4.4 Editor function list

The editor maintains a popup list of functions defined in the edited document. The list is available in the toolbar and is updated as you type. Selecting a function from that list causes the cursor to jump to the beginning of the function.

Next: Editor (internal and external), Previous: Editor function list, Up: General Features

2.4.5 Editor syntax coloring

The editor supports syntax-highlighting for R code. It is possible to change the syntax highlighting colors using the Syntax Color Preference Pane (see below). Starting with R.APP version 1.17 lazy syntax highlighting is used, which means that changes influencing the entire file (such as typing a single or double quote) no longer apply to the entire file, but only a few lines. This temporary state is usually recovered by closing the quote, but in some rare instances it may persist until a change is made to the first line of the offending quote. However, lazy highlighting brings huge speedup when editing large files.

Next: Editor help, Previous: Editor syntax coloring, Up: General Features

2.4.6 Editor (internal and external)

By default, the editor used is incorporated into R.APP, the Mac OS X GUI for R. It is arelatively simple multi-document editor that supports the features listed above. Additionally,two powerful commands are available to source the file being edited in its entirety (Command-E)or to source the current selection to R (Command-Return). Using R’s edit() function, allowsediting of R objects or files while R is kept waiting for the edit session to finish.

It is possible to ’redirect’ all R requests to an external editor, which runsoutside R.APP. In that case, it is not possible to keep R waiting if edit() is used. UsingAppleScript it is easy to implement Command-E and Command-Return like functionality.

Next: Drag & drop, Previous: Editor (internal and external), Up: General Features

2.4.7 Editor help

The editor contains a light-weight help system in form of a search filed placed inside the toolbar. It is possible to use either an exact or approximate search.

Next: Help system, Previous: Editor help, Up: General Features

2.4.8 Drag & drop

Drag and drop of a directory on the R.APP icon while R.APP is notrunning will start R.APP and set the working directory. By default.RData and the history file (default name .Rapp.history)are fetched from this working directory. If a file is dropped on theR.APP icon while R.APP is not running, R.APP is started, the fileis either restored (if it is a saved workspace), sourced into R.APP oropened in the selected editor. Whether the file is opened or sourced isspecified by a Preference setting in the StartUp Preference Pane.

Note: At this point opening a file in the editor before R.APP is finishedloading will crash R.APP.

While R.APP is running, drag & drop of a directory updates the workingdirectory. Drag & drop of a file sources or opens the file in theselected editor. Double clicking on files bound to ('Open With ...') R,if R.APP is not running, R.APP is started and the file is sourced oropened in editor. If R.APP is running, the file is opened in theeditor.

Next: History, Previous: Drag & drop, Up: General Features

2.4.9 Help system

The Help screen allows a user to go back or forward to previous helppages. It is possible to print help pages. If a help topic is notfound, a pop-up window allows to exit the help search or expand thesearch to a fuzzy/approximate search.

Next: Authentication and .libPaths, Previous: Help system, Up: General Features

2.4.10 History

R.APP uses history files that are (superset) compatible with historyfiles created by R. Multiline support remains available from insideR.APP. Multiline is particularly useful when using theCommand-Return feature while editing an Rscript. Import and export allows storing and importing history fromfiles visible in the Mac OS Finder. Multiline is preserved. This can beset through the StartUp Preference Panel. Default number of kept historyentries is 250. A variety of history entry cleanup modes is possible.At a minimum it is suggested to select 'Cleanup history entries'. It’soptional to select removal of duplicate entries and strip comments.

Note: Command-line R stores history in a file usually called.Rhistory. It is suggested to use a different name for theR.APP history file, and the default is .Rapp.history.

Note that the functions loadhistory(), savehistory() andhence history() are not currently supported in R.APP.

2.4.11 Authentication and .libPaths

The official CRAN binaries come pre-packaged in such a way thatadministrator have sufficient privileges to update R and installpackages system-wide. However, the default Unix build requiresroot-authentication for package installation and other administrativetasks. As it is not feasible to run the GUI as root, we provide thepossibility to authenticate system commands issued from the GUI. Theauthentication requires an administrator login and causes all subsequentsystem commands to be executed as root. Use with care!

In order to allow non-administrators to maintain their own set ofpackages, R.APP optionally adds ~/Library/R/x.y/library to the.libPaths (see start-up preferences, x.y denotes the Rversion without patch level). It is possible to use the PackageInstaller to install packages either globally (admin users only) or forthe current user only. (This is the same mechanism for personal librarydirectories described in the main R documentation, but with a locationspecific to CRAN-like builds of R on OS X.)

Note that user-local packages are only used when the correspondingpreference option is enabled. The default for admin users is to usesystem-wide directories, for non-admin users the personal librarydirectory will be used.

Next: Preferences, Previous: General Features, Up: R.app

2.5 The Menus

• Application Menu:
• File Menu:
• Edit Menu:
• Misc Menu:
• Workspace Menu:
• Packages Menu:
• The Help Menu:

Next: File Menu, Previous: The Menus, Up: The Menus

2.5.1 Application Menu

The Application menu is the first one after the main Apple Menu: it islabelled R.

With this menu you can access three items: 1. the About box, which tellsyou which version of R is currently in use, 2. Check for updates, whichsearch on CRAN if a new version of the binary distribution of Rfor Mac OS X is available (you need an Internet connection), 3. you canaccess the Preferences (see Preferences).

Next: Edit Menu, Previous: Application Menu, Up: The Menus

2.5.2 File Menu

This menu provides standard functionalities. The open command is associated to the action Source R code, which means that you can select a file, which is a script, and it will be executedin R. This is a interface to the R source command source.

Next: Misc Menu, Previous: File Menu, Up: The Menus

2.5.3 Misc Menu

Apart for standard functionalities, the only relevant item in this menuis Edit Object which is an interface to the Reditfunction.

Next: Workspace Menu, Previous: Edit Menu, Up: The Menus

2.5.4 Misc Menu

For

With this menu you can load and save the history of commands typed in the R Console or view what’s currently inside.You can also change the current working directory, let R show you the current working directory or set it back to thestartup directory. From release 1.9.0 of R the current working directory is also shown on the main window bar.

Next: Packages Menu, Previous: Misc Menu, Up: The Menus

2.5.5 Workspace Menu

Here you find self explanatory menu items for manage your workspace inR. You can either load and save the workspace also by specifying filename. All of these are interfaces to the load andsaveR commands. The only relevant item, which is specificto this GUI, is Browse workspace which invokes thebrowseEnv() function in R. This will open a window with asummary description of the objects in your workspace. Recursive objects(like lists, data.frame etc) can be expanded (one level only though).

Next: The Help Menu, Previous: Workspace Menu, Up: The Menus

2.5.6 Packages Menu

Using this menu you can have access to the list of packages anddata-sets installed on your system and to the ones on CRAN or on theBioconductor site.

With the first two menus you can load and detach packages and cellspacing='0'>• Startup:

2.6.1 Startup

The Drag & drop section defines drag & drop behaviour during Rstart-up. Options are to open file in an editor or to sourcefile. Default is to source the file. The Default Library Paths sectionenables, on next start-up of R, to add a directory, e.g.~/R/Library, to the library search/install path. The initialworking directory section can be used to enforce the initial workingdirectory. If no directory is specified, this directory is used as thedefault. The Change button allows to select a new directory. The Alwaysapply selection will enforce the specified intial start-updirectory. The history section controls reading of the history file onstartup. If selected, R will read history file on start-up. The Rhistory file field is used to read and store history from/to. This fieldcan be edited to allow selecting files starting with a period (e.g..Rapp.history). If you want the same history file regardless ofyour selected working directory, specify a fixed path (e.g.~/.Rapp.history). The Default button will reset the history filename to its default value. The History handling area allows setting ofthe max number of entries to be kept in history, to remove duplicateentries, to cleanup history entries (this is very useful to remove blanklines when submitting multiple lines using Command-Return) and the stripcomments before the entry is added to the history.

• Editor Preferences:
• Syntax Colors:
• Console Colors:
• Quartz window:

Next: Syntax Colors, Previous: Startup, Up: Startup

2.6.1.1 Editor Preferences

If Built-in editor is selected, allows enable/disable of syntaxcoloring, brace highlighting and the showing of line numbers. IfExternal editor is selected, allows specifying which externaleditor. That editor will be used for all editing functions. It runs as aseparate application. Using an external editor means that R will neverwait while editing (e.g. edit(A) will return immediately andopen A in the external editor. Command-E and Command-Return likefunctionality would need to be implemented by other means,i.e. AppleScript. The external editor can be any application(e.g. SubEthaEdit, TextWrangler, BBEdit, Smultron, etc) or can beactivated through a shell script (e.g. see or smultron, both give bettercontrol on how to start the editor).

Next: Console Colors, Previous: Editor Preferences, Up: Startup

2.6.1.2 Syntax Colors

Enables to select the syntax colors.

Next: Quartz window, Previous: Syntax Colors, Up: Startup

2.6.1.3 Console Colors

Enables to select the input/output colors in R Console.

2.6.1.4 Quartz window

Currently the the Quartz preference pane is not being used.

Previous: Preferences, Up: R.app

2.7 R.app Bugs

On Unix systems a bug report can be generated using the functionbug.report(). Alternatively the bug report can be submitted tothe Web page at http://bugs.R-project.org/.

Before you file a bug report, please try to reproduce it using bothR.APP and the console version of R (if applicable). If the bug ifR.APP-specific, please report the bug to the mailing listR-SIG-Mac@R-project.org instead. Please do NOT forget tomention the exact R.APP version and include the output ofsessionInfo().

In any circumstances, in case of a crash, please report the crash.logfor the R.bin and/or R.app application. You can get thiscrash.log using the Console.app located inside/Applications/Utilities (select ‘1’ in the crash menu in the Rconsole at the time of the crash (if you see that menu) to generate acrash report).

Next: R and external applications, Previous: R.app, Up: Top

3 How to install packages

You have several options for installing new packages on your system. Wediscuss here only the GUI interface to the standard R functions likeinstall.packages(). For the R functions see the standard Rdocumentation.

• Which kind of packages can I install using the GUI?:
• Installation of packages:
• Installation of source packages:
• Where are the packages I've installed?:

Next: Installation of packages, Previous: How to install packages, Up: How to install packages

3.1 Which kind of packages can I install using the GUI

GUI provides direct access/download/installation of packages located onCRAN, the Bioconductor repositories or a custom repository. You canalso install packages from local files, either binary of sourcepackages, as explained below. Otherwise you can use the appropriate Rcommands (see install.packages) to install packages from aspecific location other than the above mentioned ones.

Next: Installation of source packages, Previous: Which kind of packages can I install using the GUI?, Up: How to install packages

3.2 Installation of packages

R for Mac OS X recognizes packages in two forms: binary packages and source packages.

Binary packages are R packages in ready-to-use form, such that noadditional tools are necessary for their use. Binary packages arespecific for a given R version and OS. CRAN and Bioconductorrepositories offer R packages in binary form for the last releasedR version. Unlike on other Unix systems, R for Mac OS X installsbinary packages by default, i.e. install.packages will look forbinary repositories unless instructed otherwise.

Source packages are general in that they can be used on any platform andOS supported by R, but they need to be processed and/or compiledbefore they can be used. Additional tools may be necessary for that, seesee Installation of source packages for details. For most usersbinary packages are sufficient (if available and current).

On Mac OS X packages can be installed in three ways:

  • Using Package Manager in the R.APP GUI (recommended for most Mac users)
  • Using install.packages command in R
  • Using R CMD INSTALL command in the shell (aka Terminal)

The latter two methods are common to all Unix systems and as such described in the general R documentation. In the following we will concentrate on using the Package Installer.

If you decide to install packages you should use the Packages & Data menu of the GUI, in particular the sub-item Package Installer. Select the repository, package type (binary or source) and press Get List. This will connect to the repository through the Internet and a list all packages available for installation. The list tells you if a package is already installed on your system, the version of the package available on CRAN and the version of the same package if already installed.

You can use the search field to narrow the list of package to those matching your search criteria. Additionally you can use the search list menu to list only packages that are already installed on your system which is useful for comparing versions of available and installed packages. Finally, you can filter down to packages that have been installed by a previous R version as to allow a simple upgrade.

Select any package you want to install and press the Install button. You can follow the progress of the installation in the R Console. Once the required packages are installed, the list is re-loaded to reflect the versions of newly installed packages.

If you want to update all packages to the latest version, select the repository to use for the packages and press Update All. R will automatically determine the list of packages that can be updated and present you with a selection of packages to update.

You can also download any other package from the Internet yourself and decide to install it from source. In such case select one of the local entries in the top left list and press the Install button (which is now enabled).

Packages can also be installed from other repositories by selecting Other Repository source. Enter the repository URL in the adjacent field. Note that currently the Package Installer assumes that custom repositories maintain proper hierarchy for both source and binary packages the same way CRAN does when using Other Repository. If your custom repository is flat, select Other Directory URL in the installation type list.

Next: Where are the packages I've installed?, Previous: Installation of packages, Up: How to install packages

3.3 Installation of source packages

Source packages which do not contain compiled code can (with rareexceptions) be installed with no additional tools.

Packages with compiled code (or some with Unix scripts) need the toolsused to build R itself discussed in the ‘R Installation andAdministation Manual’, and these will need to be in the ‘PATH’ asseen from R.APP or command-line R. For R.APP you may need to adde.g. /usr/local/bin and it is usually most convenient to usecommand-line R.

If using a CRAN binary install of R the compilers may not be in thesame place or have the same names as on the CRAN build machine. Look atfile /Library/Frameworks/R.framework/Resources/etc/Makeconf,which will contain lines like

You can either edit that file, or override settings in file~/.R/Makevars: see the section ‘Customizing package compilation’of the ‘R Installation and Administration Manual’.

Previous: Installation of source packages, Up: How to install packages

3.4 Where are the packages I’ve installed?

The main library of packages is the one located inside the R.framework(in /Library/Frameworks/R.framework/Resources/library). Thislibrary contains the packages (base and recommended ones) distributedalong with R. Only administrators are allowed to install packages inthis system-wide directory. Note that this directory isR-version-specific. Optionally users can install personal packages intheir ~/Library/R/x.y/library directory where x.y denotesthe R version without the patch level (such as 3.0) – see the startuppreferences in R.APP.

The Package Installer performs installation to either place depending onthe installation target setting. The default for an admin users is toinstall packages system-wide, whereas the default for regular users istheir personal library tree.

If you use install.packagesR function instead ofthe Package Installer, the regular Unix behavior applies (see help pagesfor details). For default setup this means that the packages areinstalled according to the startup preference setting. You can check thecurrent defaults by issuing

Next: Quartz device, Previous: How to install packages, Up: Top

4 R and external applications

• AppleScript support:
• External editors:
• Finder actions:

Next: External editors, Previous: R and external applications, Up: R and external applications

4.1 AppleScript support

R has partial support for Apple-Scripts. At the moment R can beinvoked and asked to run commands from an AppleScript script. Whatfollows is an example of script that interacts with R. It firstinvokes R and then sends commands to R with the cmdapplescript command.

In the above, cmd is the (only) applescript command in the R dictionary that is used to tell R to execute an R command in the R Console. The syntax is

where command string have to be in quotes. Actually, the output of the commandis not sent back to the application that is calling R but to the R Console directly.

There are some issues. The first is that if R is still not running,it will take a while (depending on how fast your machine is) tostartup. In the meanwhile the script sends commands without waiting andit could happen that some commands are missed by R, i.e. they arrivebefore R is ready to receive applescript commands. The second issue,is that it could be that the applescript calls a bad version ofR. This could happen if you have an old version of R (for examplethe old Carbon R) installed on your System.

As an example, we report here a small script that asks R to source a file using a file dialog.

Next: Finder actions, Previous: AppleScript support, Up: R and external applications

4.2 External editors

R accepts the Apple Event command open. This means than anexternal editor can communicate with R sending portions of R codeto execute via files. This is the approach used by the R-Tcl Mode inAlpha X (see http://www.kelehers.org/alpha/).

Previous: External editors, Up: R and external applications

4.3 Finder actions

Dragging a file on the R icon, causes R to source this file viathe sourceR command or, if the file is an R image datafile RDX1 or RDX2 (normally files with extension .rda or.RData), the data is loaded in the workspace and every objectwith the same name in the workspace is overwritten withoutnotice. Loading a data file is equivalent to the R commandload. At the moment there is no control over the file types,i.e. dragging wrong files (i.e. files that are not R scripts or imagedata) simply gives an error. It is up to the user to do the rightthing.

If R is not yet running this action causes R to startup.

Next: Tcl/Tk issues, Previous: R and external applications, Up: Top

5 Quartz device

The quartz() device is the native graphic device in R for Mac OSX. Its name derives from Apple’s Quartz Technology which is essentiallysimilar to PDF rendering.

The quartz() device can be used from R.APP or a suitable build of Rrunning at the Mac console. Where supported it is the default graphicsdevice.

• Interactive mode:
• Saving the image:
• Copying the image into the clipboard:

Next: Saving the image, Previous: Quartz device, Up: Quartz device

5.1 Interactive mode

The quartz device allows for interaction. You can use bothidentify and locator functions. To break thesequence you should right/control-click or hit the ESC key.

Next: Copying the image into the clipboard, Previous: Interactive mode, Up: Quartz device

5.2 Saving the image

You can save the content of the quartz device window into a PDF file,via the R menu when the device window has focus. This is a simpleway to export high quality graphics from R into other applications onMac OS X as graphics is PDF-based (so are almost all applicationsavailable). For other solutions, see (see Copying the image into the clipboard) and the quartz.save function.

5.3 Copying the image into the clipboard

You can copy the content of the quartz device window in the clipboard tomake the resulting image available for pasting into otherapplications. The clipboard will contain both a PDF version and a bitmapversion of the quartz device window. Which version will be used dependson the pasting applications, most modern application will prefer the PDFversion which is of higher quality as it supports vector graphics.

Next: Internationalization of the R.app, Previous: Quartz device, Up: Top

6 Tcl/Tk issues

Each binary distribution of R available through CRAN is built touse the X11 implementation of Tcl/Tk. Of course a X windows server hasto be started first: this should happen automatically on OS X, providedit has been installed (it needs a separate install on Mountain Lion andlater). The first time things are done in the X server there can be along delay whilst a font cache is constructed; starting the server cantake several seconds.

Mac OS X 10.9 and higher no longer include X11by default and it has to be obtained separately fromhttp://xquartz.macosforge.org.

If you don’t like the X11 style of widgets and use command-line R youwould probably want to build R using the Aqua version of Tcl/Tk (see the‘R Installation and Administration Manual’). Note, however, that suchbuilds do not work when used in the R.APP GUI.

Next: Additional resources, Previous: Tcl/Tk issues, Up: Top

7 Internationalization of the R.app

R and the R.APP GUI introduced support for internationalization inR 2.1.0. Among other things this means that both messages and GUIelements can be translated into various languages. R.APP automaticallydetects user’s settings in the International section of theSystem Preferences and uses that information to offer translatedmessages and GUI if available. Please note that both Language andFormats information is used so they should be set upconsistently.

If you use a non-standard setup (e.g. different language thanformats), you can override the auto-detection performed by setting‘force.LANG’ defaults setting, such as for example

when run in Terminal it will enforce US-english settingregardless of the system setting. If you don’t know what Terminalis you can use this R command instead:

but do not forget to quit R and start R.APP againafterwards. Please note that you must always use ‘.UTF-8’ versionof the locale, otherwise R.APP will not work properly.

By default R.APP uses UTF-8 for newly created documents and for theconsole. When opening new documents R.APP assumes UTF-8 and only ifthe document violates UTF-8 rules, it will try to fallback to legacyencoding, usually Mac Roman.

If you are interested in translating R.APP GUI into other languages,please read the developer documentation athttp://developer.r-project.org/Translations30.html.

Next: Acknowledgments, Previous: Internationalization of the R.app, Up: Top

8 Additional resources

Here are few references that can be of interest for Mac OS X and/or developers.

• Apple Developer Connection:
• The R for Mac OS X Developer page:

Next: The R for Mac OS X Developer page, Previous: Additional resources, Up: Additional resources

8.1 Apple Developer Connection

The Apple Developer Connection (can be reached athttp://developer.apple.com) is the main source of information forApple products (OS, hardware, software) for developers. You cansubscribe for free to ADC and get the latest up-to-date tools from Apple(compilers for example): however more recently these have beendistributed through the App Store.

Previous: Apple Developer Connection, Up: Additional resources

8.2 The R for Mac OS X Developer page

There is a page dedicated to development versions for R for Mac OS X. This page is located athttp://R.research.att.com/ and is maintained by Simon Urbanek.It contains latest nightly builds of R and R.APP as well as information on tools necessary to build R.

Next: Miscellaneous questions, Previous: Additional resources, Up: Top

9 Acknowledgments

Special thanks go to Jan de Leeuw, Byron Ellis and Thomas Lumley inrandom order. Last but not least Apple for amazing OS and GUI.

10 Miscellaneous questions

• How can I have a per session .Rprofile?:
• What happens if I drag a file on the R icon?:
• How can I interrupt lengthy operations or output?:
• I see spurious error messages when starting R!:
• Which BLAS is used and how can it be changed?:
• I don't see a thing when installing packages!:
• Why are there faint lines in image plots?:
• Why doesn't R GUI support keyboard shortcut XYZ ?:
• What is the difference between the CRAN build and a vanilla build?:
• Why is R.home() not versioned?:
• R.app GUI crashes on startup!:
• Why is the GUI not saving my history?:
• I get ``command not found' in the GUI yet it works in the Terminal -- why?:
• I see no text in a Quartz plot!:
• I get ``clang: error: unsupported option -fopenmp' when compiling a package -- why?:

Next: What happens if I drag a file on the R icon?, Previous: Miscellaneous questions, Up: Miscellaneous questions

10.1 How can I have a per session .Rprofile?

You can by writing a .Rprofile file in your favoritesession directory and change accordingly the startup working directory using the Preferences (see The current and startup working directories).

Next: How can I interrupt lengthy operations or output?, Previous: How can I have a per session .Rprofile?, Up: Miscellaneous questions

10.2 What happens if I drag a file on the R icon?

In this case R will try to source this file or load the image data file (see Finder actions). If R is notyet running it will be launched.

Next: I see spurious error messages when starting R!, Previous: What happens if I drag a file on the R icon?, Up: Miscellaneous questions

10.3 How can I interrupt lengthy operations or output?

In R.APP you can use the the Stop toolbar button or the ESC (escape) key in the console window to interrupt a running calculation or output.

For the command line version the same is achieved by pressing Ctrl-c. Both applications honor the INT signal, i.e. you can type the following in a separate Terminal window to cancel all R computations:

However, if the executed code does not check for interrupts (using ‘R_CheckUserInterrupt’) there may be no way of stopping R. In that case it may be worth alerting the maintainer of the package to allow interruption (if appropriate).

Next: Which BLAS is used and how can it be changed?, Previous: How can I interrupt lengthy operations or output?, Up: Miscellaneous questions

10.4 I see spurious error messages when starting R!

If you see error messages upon start of the R GUI which containLibrary/InputManagers anywhere in the text, then you have somebroken haxxies installed in your system. Those messages do NOT come fromR, so don’t blame us. Bundles located in Library/InputManagersof your home (or system) are hacks that get loaded into every Macapplication that you start. In most cases you don’t see them crashing,because most applications don’t show the console output, but R does,so all the errors those hacks are causing become visible. The easiestremedy is to delete all offending bundles (possibly the wholeLibrary/InputManagers folder) and get a fixed version of the hack(if you need it). The most common cause for broken hacks is systemupdgrade (e.g. you get a new Mac and you transfer you settings whichinclude those hacks that are incompatible with your new Mac).

If you want to disable all external error output in the GUI, use

in the Terminal. Note, however, that this will disable all error output from external programs including package installation or the system command.

Next: I don't see a thing when installing packages!, Previous: I see spurious error messages when starting R!, Up: Miscellaneous questions

10.5 Which BLAS is used and how can it be changed?

The BLAS library used by R depends on the way R was compiled (see‘R Installation and Administration’ manual for details). Current Rbinaries supplied from CRAN provide both vecLib-based BLAS andreference BLAS shipped with R. vecLib is a part of Apple’s Accelerateframework which provides an optimized BLAS implementation for Machardware. Although fast, it is not under our control and may possiblydeliver inaccurate results.

The CRAN binary uses --enable-BLAS-shlib option and two Rblasshared libraries are supplied: libRblas.vecLib.dylib which usesvecLib BLAS and libRblas.0.dylib which uses reference BLAS fromR. A symbolic link libRblas.dylib determines which one isused. Currently the default is to use the R BLAS: this is recommendedfor precision.

Studio

In order to change which BLAS is used, change the libRblas.dylibsymlink correspondingly – for example in Terminal:

This feature is only present in the RCRAN binary. Ordinarilycompiled R from sources will only have one of the above BLASlibraries, corresponding to the configuration options used.

Next: Why are there faint lines in image plots?, Previous: Which BLAS is used and how can it be changed?, Up: Miscellaneous questions

10.6 I don’t see a thing when installing packages!

The output is not produced continuously during the packageinstallation. R.APP does its best to display the output as soon aspossible, but for example the documentation script does not printanything until done.

Also note that the development build of R.APP sends output to theerror console instead of the screen. You may want to check theConsole application in that case.

Next: Why doesn't R GUI support keyboard shortcut XYZ ?, Previous: I don't see a thing when installing packages!, Up: Miscellaneous questions

10.7 Why are there faint lines in image plots?

When plots based on the image() function are exported to PDF,Preview shows very faint grid lines at the edges of the rectangles thatcreate the image. Those lines are a rendering artifact in Preview comingfrom the combination of anti-aliasing and sub-pixel rendering. They arenot really a part of the PDF (zooming in will reveal that they are not areal object which would get larger with zoom) since the rectangles aredefined as a gapless coverage of the area. The effect can becircumvented by disabling anti-aliasing in Preview.

We correct for this effect in Quartz when rendering on-screen bysnapping all rectangles to pixel boundaries of the screen, but Previewdoes not.

The same effect occurs in any plot with adjacent, filled polygonswithout border.

Next: What is the difference between the CRAN build and a vanilla build?, Previous: Why are there faint lines in image plots?, Up: Miscellaneous questions

10.8 Why doesn’t R GUI support keyboard shortcut XYZ ?

R-studio For Mac Serial

The R.APP GUI uses Apple frameworks for text editing and thus thebehavior of text views (console, editor, etc.) is consistent with otherapplications and allows a very flexible customization. For example ifyou are not satisfied with the default Emacs-like key bindings that MacOS X provides, Apple allows you to extend them arbitrarily. For moredetails see Apple’s documentation onKey Bindings. There are also many 3rd-party pages on key bindingscustomization, search for StandardKeyBinding.dict.

Next: Why is R.home() not versioned?, Previous: Why doesn't R GUI support keyboard shortcut XYZ ?, Up: Miscellaneous questions

10.9 What is the difference between the CRAN build and a vanilla build?

The CRAN build of R is slightly different from a vanilla build of R,i.e., a simple ./configure && make && make install. The defaultpackage type for all builds compiled from sources is 'source'wheres CRAN uses binary packages. Only the CRAN build isguaranteed to be compatible with the package binaries on CRAN (orBioconductor).

Next: R.app GUI crashes on startup!, Previous: What is the difference between the CRAN build and a vanilla build?, Up: Miscellaneous questions

10.10 Why is R.home() in the R framework not versioned?

In the command line version of R, R.home() always points to theResources directory symbolic link inside the R framework whichpoints to Versions/Current/Resource which is turn points to theactual home – a versioned directory such as for exampleVersions/3.0/Resources. This is how framework versioning worksin Mac OS X and is defined by Apple (seeFramework Anatomy).

The advantage of this setup is that it is possible to install multiple Rversions in parallel and they all will be fully functional as long asthe Current symbolic link points to the currently usedversion. There is even a small GUI utility RSwitch available fromthe R for Mac devel page that allowsyou to select the desired version. In addition, any applicationembedding R can choose to use a specific R version (in most cases) orany version. Note that R.APP is compiled against a particular versionof R and it may crash if RSwitch is used to change the versionof R in use.

Although it is possible to set R_HOME directly to the versionedpath in the R shell scripts (and thus be able to run different versionin parallel without changing the symbolic link), there are severaldangers lurking there so we don’t recommend it. One problem is thatbuilding packages from source won’t work. The linker is always linkingagainst the current version of the framework and therefore only thecurrently active version of R can compile packages. Further, packagesmay have used the value of R.home() at install time and thus maynot work with incorrect setting. Finally, if such an R start scripthappens to get copied and the R version changes, it will stop working.

Next: Why is the GUI not saving my history?, Previous: Why is R.home() not versioned?, Up: Miscellaneous questions

10.11 R.app GUI crashes on startup!

If your R.APP GUI crashes on startup, there are two common causes forthis: a saved workspace or a corrupted history file. (Another is amismatch between R.APP and R if either has been updated orRSwitch has been used.)

Saved workspaces can contain commands that implicitly load packageswhich in turn can trigger bugs in packages or feed R with incorrectstarting values (especially if it was saved using another R). Tryremoving or renaming your workspace – it’s called .RData. If youdid not change your startup settings, you can e.g. use

to move it aside and load later manually for inspection using load('~/workspace.RData').

Second most common cause of crashes on startup is a history file thatwas not created using the R.APP GUI. Again, move it aside to see ifthat’s the issue: for the default file this could be done by

Although we are trying to recover from invalid history files, they canstill crash R.APP due to issues in the internal handling of strings inMac OS X. We are currently working on preventing this issue.

If you did both of the above and R.APP still crashes, please select‘1’ in the menu after the crash (if you get the crash menu in theconsole) and send us the resulting crash report (see see R.app Bugsabove).

Next: I get ``command not found' in the GUI yet it works in the Terminal -- why?, Previous: R.app GUI crashes on startup!, Up: Miscellaneous questions

10.12 Why is the GUI not saving my history?

R.APP will by default save the history in a .Rapp.history filewhereas command line R will use .Rhistory. So the savedhistory is only used in subsequent R.APP sessions and not command-lineR, and conversely.

Note that calling savehistory() in R.APP does not currentlysave the history of the R.APP session: this means thathistory() will show an empty window.

Next: I see no text in a Quartz plot!, Previous: Why is the GUI not saving my history?, Up: Miscellaneous questions

10.13 I get “command not found” in the GUI yet it works in the Terminal – why?

When executing system commands (for example directly via system or indirectly via functions that call other programs such as install.packages) the locations in which the shell is looking for programs is governed by the PATH environment variable. That variable may be set differently for R started from an interactive shell and for R started in the GUI. You can use Sys.getenv('PATH') to verify the current setting.

When R is started from a shell (e.g., on the command line of the Terminal), it will inherit settings from that shell. Those are typically modified by shell-specific configuration files, such as .profile or .bashrc. Those apply only to the shell, not to the system as a whole. In addition, some installers (such as MacTeX) will modify global shell settings to make user’s life more comfortable on the command line, but, again, those do not apply to programs not started from the shell – such as GUIs. See Apple Technical Q&A QA1067 for what Apple says about the topic.

In order to standardize your PATH setting in R, you can set it inyour .Renviron file (in your home directory – see ?Startupin R for details on how R uses configuration files on startup). Thissetting will apply to R regardless of how it is started. You can alsoadd more elaborate constructs to .Rprofile instead if you wish toselectively modify the existing PATH variable viaSys.getenv and Sys.setenv.

Next: I get ``clang: error: unsupported option -fopenmp' when compiling a package -- why?, Previous: I get ``command not found' in the GUI yet it works in the Terminal -- why?, Up: Miscellaneous questions

10.14 I see no text in a Quartz plot!

Typically this means that you have corrupted fonts in your system. Openthe Font Book application (in Applications) and check thefonts that you are using (for example the default font in Quartz iscurrently “Arial”). Corrupted fonts will have no glyphs (text will notappear as it should), remove such fonts.

Previous: I see no text in a Quartz plot!, Up: Miscellaneous questions

R Studio For Mac 10.10.5

10.15 I get “clang: error: unsupported option -fopenmp” when compiling a package – why?

CRAN binaries for the El Capitan build (the main build since R 3.4.0) come with OpenMP support (it is a way to parallelize many operations and thus make R faster), which is only available in recent Clang compilers. In order to compile packages you must install a Clang compiler with OpenMP support, we provide one in the tools section on CRAN: https://cran.r-project.org/bin/macosx/tools/. Apple’s Clang that comes with Xcode does not support OpenMP and thus cannot be used. For details please see the instructions on the aforementioned CRAN tools page – for example, if you use our clang binary then you can set PATH=/usr/local/clang6/bin:$PATH or set the full paths to the tools in ~/.R/Makevars. If you see the error clang: error: unsupported option '-fopenmp' then you are not using the correct clang compiler.