Skip to content

Instantly share code, notes, and snippets.

@mbostock

mbostock/R Secret

Last active August 29, 2015 14:06
Show Gist options
  • Save mbostock/5bf494c4629b6b9f0d05 to your computer and use it in GitHub Desktop.
Save mbostock/5bf494c4629b6b9f0d05 to your computer and use it in GitHub Desktop.
R: command not found
# My experience trying to run a 7-line R script.
$ make
R --no-save --slave < r-work/sketch.R
/bin/sh: R: command not found
make: *** [public/_assets/smoothed.csv] Error 127
$ brew install R
Error: No available formula for r
$ google R
http://www.r-project.org/
$ download http://cran.cnr.berkeley.edu/bin/macosx/
Please wait…
$ make
R --no-save --slave < r-work/sketch.R
Error in library(caTools) : there is no package called ‘caTools’
Execution halted
make: *** [public/_assets/smoothed.csv] Error 1
$ R
> install.packages('caTools')
--- Please select a CRAN mirror for use in this session ---
Error: XQuartz is not installed
$ google XQuartz
http://xquartz.macosforge.org/landing/
$ download http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.7.dmg
Please wait…
$ R
> install.packages('caTools')
--- Please select a CRAN mirror for use in this session ---
Please wait for X11 to start…
Error: XQuartz is out of date
Error: An error occurred during installation
Error: X11 has quit unexpectedly
The downloaded binary packages are in
/var/folders/9p/jxyzkmv93mxcfrbg6h0d12000000gn/T//Rtmp5dwLDx/downloaded_packages
$ make
R --no-save --slave < r-work/sketch.R
$ rejoice
@jiffyclub
Copy link

There is an R recipe for Homebrew, but it's r, not R.

Edit: R seems also to work.

> brew info r
r: stable 3.1.1, HEAD
http://www.r-project.org/
/usr/local/Cellar/r/3.1.1 (2148 files, 58M) *
  Built from source
From: https://github.com/homebrew/homebrew-science/blob/master/r.rb
==> Dependencies
Required: readline ✔, gettext ✔, libtiff ✔, jpeg ✔, cairo ✔
Optional: valgrind ✘, openblas ✘
==> Options
--with-librmath-only
    Only build standalone libRmath library
--with-openblas
    Build with openblas support
--with-valgrind
    Build with valgrind support
--without-accelerate
    Build without the Accelerate framework (use Rblas)
--without-check
    Skip build-time tests (not recommended)
--without-tcltk
    Build without Tcl/Tk
--without-x11
    Build without x11 support
--HEAD
    install HEAD version
==> Caveats
To enable rJava support, run the following command:
  R CMD javareconf JAVA_CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

@jamestwebber
Copy link

You have to brew tap homebrew/science first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment