It is a pain in the A-word. I get it work, but not for every PC. Please follow my process:
- Set up the global environment variables.
(a). Right click "My Computer", choose "Property"
(b). Choose "Advanced System Settings"
(c). Choose "Environment Variables"
(d). Click "New..." and add the following variables:
Variable Name=R_HOME
Variable Value=~R\R-3.0.1 (This should be the folder of R. No need to go down to "bin" folder.)
Variable Name=R_USER
Variable Value=John Smith (This should be your user name to log in windows os)
Then, double click "PATH" variable to add the R folder location at the end of the sentence (separated by ";")
- Install RPY2 through pre-compiled binary packages:
Provided by Christoph Gohlke
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Install the binary package after downloading.
- Copy core R files to the correct directory
rpy2 package will automatically dive into "bin" folder to call R.exe; however, the core R files are located one level below (64-bit: bin\x64 or 32-bit: bin\i386). For example, assuming you wish to use 64-bit R in iPython Notebook, to make RPY2 work properly, you need to make sure that you copy everything , except R.exe and Rscript.exe, to the bin folder.
Then you should be able to load rpy2, call rmagic and enjoy.