R nightmare: Yosemite, R, RStudio, and Homebrew

2019-03-09 01:58发布

问题:

I use a MacBook Pro 13" Retina (Late 2013) with OS X Yosemite 10.10.2. I wouldn't wish this upon my worst enemy. Well maybe.

Nightmare in chronological order:

  1. Downloaded R and RStudio from official sites.
  2. Ran both apps a few times, fine.
  3. Installed Homebrew. Ran "brew doctor" in Terminal. Brew doctor said the R files were problematic.
  4. RStudio started acting weird.
  5. Downloaded ggplot2 R package via CRAN mirror. 5GB of data clogged the "private/var" file. Deleted some data in there.
  6. Mac freaked out. Kernel panic until an Apple Store Genius erased the Mac and reinstalled OS X.

I want to continue using R and RStudio. Questions:

  1. How do I go about this without blowing up the Mac again?
  2. How to install R and RStudio via Homebrew?
  3. Do I need to install XQuartz first?
  4. What would happen if I install R and RStudio unbrewed?
  5. What conflicts between R, RStudio and Homebrew should I recognize?
  6. Common quirks of having all of Homebrew, R, and RStudio installed?
  7. How can I make Homebrew, R, and RStudio live happily ever after without burning down the house?

Thanks!

回答1:

How do I go about this without blowing up the Mac again?

Don't try to delete your swap file while the computer is running! If you start deleting random system files you're going to have a bad day.

How to install R and RStudio via Homebrew?

You can install R with brew install r. You can install a binary RStudio using homebrew-cask, like brew install Caskroom/cask/rstudio.

Do I need to install XQuartz first?

No, this should no longer be necessary.

What would happen if I install R and RStudio unbrewed?

Nothing bad; brew doctor may report findings but these are not errors and you should not assume they represent problems, though they are helpful to maintainers like me if you seek help trying to diagnose build failures later.

What conflicts between R, RStudio and Homebrew should I recognize?

There are no important conflicts. If you install the compilers from http://r.research.att.com/libs/, which are unnecessary if you're using a brewed R, you may later have trouble installing things like gcc (which provides gfortran) from Homebrew.

Common quirks of having all of Homebrew, R, and RStudio installed?

As of August 2015 the comments below are no longer necessary; packages are now installed to /usr/local/lib/R/x.y/site-library by default and should survive minor R upgrades.

If you are using a brewed R and you would like your installed packages to survive minor R upgrades, you can run mkdir -p ~/Library/R/3.2/library and then R will install packages to that path by default (placing the packages in your home directory and not in the Cellar).

How can I make Homebrew, R, and RStudio live happily ever after without burning down the house?

See above!



回答2:

Looking back at this issue, considering all the helpful comments and answers, regarding downloading R packages on a Mac with R and Homebrew already installed:

Do it in the R console within the RStudio interface, simply by typing install.packages("name of the package")

Since I had started downloading R packages directly in RStudio, I hadn't had any problems. The system is very happy.