stat157 / questionnaire

Stat 157 Questionnaire Data Wrangling
1 stars 23 forks source link

Using R code within Python. #47

Open arifyali opened 10 years ago

arifyali commented 10 years ago

Part of my group is unable to work in python and must work in R, is there any way to merge within python??

kqdtran commented 10 years ago

So my group is not using R with Python, but I would check out some of the links below:

http://heather.cs.ucdavis.edu/~matloff/rpy2.html Tutorial on using R with Python http://stackoverflow.com/questions/tagged/rpy2 All SO questions tagged with 'rpy2' http://rpy.sourceforge.net/rpy2/doc-2.3/html/ Documentation for rpy2 And finally, you can install it with sudo pip install rpy2

aculich commented 10 years ago

@kqdtran Where possible try using the Ubuntu packages first by installing sudo apt-get install python-rpy2 instead of using pip. Often there are dependencies that need installed that will be handled by the Ubuntu packaging system.

On the other hand, if you have a specific version requirement for the latest released version then pip is a good strategy to use. You can check the relative versions and decide which way you need to solve the problem depending on how old the Ubuntu package is compared to the (more recent) pip version.

For example, for rpy2:

$ dpkg -l python-rpy2
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name              Version       Architecture  Description
+++-=================-=============-=============-========================================
ii  python-rpy2       2.3.1-2       amd64         Python interface to the GNU R language a
$ pip search rpy2
rpy2                      - Python interface to the R language (embedded R)
  INSTALLED: 2.3.1
  LATEST:    2.3.8

In this example the version available for Ubuntu 13.10 is rpy 2.3.1 and the pip version is only slightly more recent with a minor revision update of 2.3.8, so installing the Ubuntu package is more likely to be reproducible because the next time you do a pip install it may be a much later version, whereas Ubuntu package versions are relatively much more stable.

Your suggestion was a good one, however I did want to point out this particular distinction to consider.

aculich commented 10 years ago

@arifyali Another link to consider beyond the great links that @kqdtran suggested is:

Using R Within the IPython Notebok