rpy2

Prepare a python string for R using rpy2

女生的网名这么多〃 提交于 2019-11-28 06:49:04
问题 This question relates to python variable to R and perhaps also to this python objects to rpy2 but none of the two completely overlaps and the first one is actually unanswered. My question is actually very simple. I have a string, say: In [21]: strg Out[21]: 'I want to go home' and I want to pass it to R through robjects.r(''' ''') like this, for example: robjects.r(''' test <- gsub("to", "",strg) ''') but of course, when I run this I obtain: Error in gsub("me", "", strg) : object 'strg' not

Python interface for R Programming Language [duplicate]

橙三吉。 提交于 2019-11-28 02:51:00
This question already has an answer here: How do Rpy2, pyrserve and PypeR compare? 4 answers I am quite new to R, and pretty much used to python. I am not so comfortable writing R code. I am looking for python interface to R, which lets me use R packages in pythonic way . I have done google research and found few packages which can do that: Rpy2 PypeR pyRserve But not sure which one is better ? Which has more contributers and more actively used ? Please note my main requirement is pythonic way for accessing R packages . gauden As pointed out by @lgautier, there is already another answer on

Use `rpy2` with packages installed for `R` in conda virtual environment?

柔情痞子 提交于 2019-11-28 02:16:22
问题 I have been trying to keep my environment non-redundant and clean so I made an R environment and wiped out all other existing R s on my computer. That environment is called r-conda and it is in: /Users/jespinoz/anaconda/envs/r-conda/bin/R I realized I didn't have rpy2 installed and to install it through conda it wanted to install the a new version of R and all of the r-essentials which I don't want since I already have a perfectly working R environment. I realized I could install rpy2 for the

Tried to guess R's HOME but no R command in the PATH. OsX 10.6

十年热恋 提交于 2019-11-27 23:43:18
问题 I am trying to install rpy2 and I am facing a common issue. Unfortunately all the solution I have found are for win7 I have installed a Python 2.7 and R 2.15. then I write on the terminal easy_install rpy2 or, alternatively pip install rpy2 Same result: Tried to guess R's HOME but no R command in the PATH What I should do? 回答1: Make sure you have R installed brew install r Then install rpy pip install rpy2 回答2: The rpy2 code is doing the wrong check. R might be perfectly fine, but rpy2 is

Rpy2 error wac-a-mole: R_USER not defined

老子叫甜甜 提交于 2019-11-27 21:26:59
问题 I'm running Python (x,y) 2.7 on windows 7 32 bit and R version 3.1.0. I've been trying to install Rpy2 and have been getting many errors. I finally found this site which has pre-compiled python modules for windows http://www.lfd.uci.edu/~gohlke/pythonlibs/, so I downloaded rpy2‑2.4.2.win32‑py2.7.exe. When I did this and tried import rpy2.robjects as robjects I had an error saying it could not find R_HOME, so I updated my path variables. This was fixed, but then I got an error saying it could

Calling R script from python using rpy2

断了今生、忘了曾经 提交于 2019-11-27 18:02:48
I'm very new to rpy2, as well as R. I basically have a R script, script.R, which contains functions, such as rfunc(folder). It is located in the same directory as my python script. I want to call it from Python, and then launch one of its functions. I do not need any output from this R function. I know it must be very basic, but I cannot find examples of R script-calling python codes. What I am currently doing, in Python: import rpy2.robjects as robjects def pyFunction(folder): #do python stuff r=robjects.r r[r.source("script.R")] r["rfunc(folder)"] #do python stuff pyFunction(folder) I am

R_HOME Error with rpy2

两盒软妹~` 提交于 2019-11-27 14:22:08
问题 I know there are quite a few posts on getting up and running with rpy2 on windows 7 32 bit. I have referenced a good number of them and attempted their solutions, including the use of PypeR . I dont explicitly have a R_HOME variable set in my path, but per this question, I confirmed that R is in my PATH (I can type R at the command line and get R to run) and even copied all of the files from the i386 folder to the parent bin folder. My issue is pasted below. Any thoughts? In [5]: from rpy2

Plotting 3-tuple data points in a surface / contour plot using matplotlib

我是研究僧i 提交于 2019-11-27 12:45:38
I have some surface data that is generated by an external program as XYZ values. I want to create the following graphs, using matplotlib: Surface plot Contour plot Contour plot overlayed with a surface plot I have looked at several examples for plotting surfaces and contours in matplotlib - however, the Z values seems to be a function of X and Y i.e. Y ~ f(X,Y). I assume that I will somehow need to transform my Y variables, but I have not seen any example yet, that shows how to do this. So, my question is this: given a set of (X,Y,Z) points, how may I generate Surface and contour plots from

Calling R Script from python in AWS lambda

旧街凉风 提交于 2019-11-27 07:29:11
问题 I know there is a package called rpy2 in python in order to integrate R and python. Calling R script from python using rpy2, in this link they have described to do normally. But in order do the same in AWS lambda, what should be the path that we can give instead of the name "folder" in this link. 回答1: I am using very simple methode for interachanging between python and R by using rpy2, here is one example where I write R script as string and then use rpy2 to translate it for R and return it

Getting Segmentation fault Core dumped error while importing robjects from rpy2

我只是一个虾纸丫 提交于 2019-11-27 06:25:27
问题 Installed R and rpy2 manually Installation is successful but getting the above mentioned error. Please help me out? Outputs of some useful commands: >>> import rpy2 >>> rpy2.__path__ ['/home/ashish/miniconda2/lib/python2.7/site-packages/rpy2-2.8.2-py2.7-linux-x86_64.egg/rpy2'] >>> import rpy2.robjects cannot find system Renviron /home/ashish/miniconda2/lib/python2.7/site-packages/rpy2-2.8.2-py2.7-linux- x86_64.egg/rpy2/rinterface/__init__.py:185: RRuntimeWarning: Fatal error: unable to open