简体   繁体   中英

R freezes in Mac OS X Yosemite

I encountered this problem and there was no clear explanation about how to work around this bug.

The latest version of R (v. 3.1.2) for OS X Mavericks freezes in Yosemite whenever I try to save a file which is written using R's internal editor. It also freezes when you try to source a function.

Edit: This was supposed to be a self-answered question, but I found a better answer, so I marked that as the answer.

I have run into the same problem. I haven't tried Metallica's answer but found the problem has 95% disappeared after installing the latest "patch" version of R , as found at att.com .

Apparently, this is a bug in R's GUI. Some OS X features/libraries that used to be in place in earlier versions of OS X have been removed in Yosemite.

You can work around this bug by running R from the terminal / command line. Fire up the terminal app (quickest way is to use Spotlight search: cmd + space -> terminal ), and type in (or paste) the following command:

/Applications/R.app/Contents/MacOS/R

Also avoid using the Misc menu or other GUI elements if you can. Using the change working directory menu entry in the Misc menu causes a freeze. You can use the R command setwd() instead, eg:

setwd("path/to/your/working/directory")

There is a problem though, you have to change your working directory every time you open up R. To make the change permanent, put the above command (setwd) in your R's init file ( .Rprofile ) in your home directory. If you cannot find .Rprofile , that is fine, create a file in your home directory, name it .Rprofile , and paste the command there. This file is executed by R every time you open up R.

The newest version (Wooden Christmas Tree 3.2.3 and the GUI 1.66) that were released on December 10, 2015 appear to have corrected this problem. It does require you have Maverick or newer OS. I've only performed limited trials, including opening with the GUI rather than through terminal, and have not had any hangs.

For anyone here with version 3.4.1 (2017-06-30) -- "Single Candle" and running Mac OS X Sierra 10.12.6 with the same problem, I find that I can usually save an image I create if I save it in the current working directory. However, if you need to save an image in a specific location and the GUI freezes up, try the following command (for pdf images):

pdf(/path/to/location/name.pdf)

plot(x, y, ...)

dev.off()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM