rpy2

Django - App crashing when using pandas2ri

半腔热情 提交于 2019-12-22 12:33:53
问题 I am implementing rpy2 code in Django and when I convert pandas dataframe into r dataframe my app starts crashing and giving error: Error: C stack usage 60820464 is too close to the limit otherwise app works fine as long as i don't convert. Is there any problem/mistake in my code? My code snippet: from .models import Values import pandas as pd from rpy2.robjects import pandas2ri pandas2ri.activate() def rpyset(request): filterdata = pd.DataFrame(list(Values.objects.all().values('val1','val2',

Migrating a logistic regression from R to rpy2

别说谁变了你拦得住时间么 提交于 2019-12-22 09:26:18
问题 I'm trying to use ryp2 to do a logistic regression. I managed to execute it, but don't know how to extract the coefficients and p-values from the result. I don't want to print the values on the screen bu create a function to use them independently. import rpy2.robjects as ro mydata = ro.r['data.frame'] read = ro.r['read.csv'] head = ro.r['head'] summary = ro.r['summary'] mydata = read("http://www.ats.ucla.edu/stat/data/binary.csv") #cabecalho = head(mydata) formula = 'admit ~ gre + gpa + rank

translating named list vectors from R into rpy2 in Python?

牧云@^-^@ 提交于 2019-12-22 05:44:12
问题 What is the equivalent of the following R code in Rpy2 in python? Var1 = c("navy", "darkgreen") names(Var1) = c("Class1", "Class2") ann_colors = list(Var1 = Var1) It's not clear what ann_colors is. When evaluated in R it gives: > ann_colors $Var1 Class1 Class2 "navy" "darkgreen" Is it an robject.ListVector ? I tried: robjects.ListVector({"Class1": "navy", "Class2": "green"}) but it's not quite it because I'm not sure how to tell the ListVector object that the name of this object is Var1 , i.e

translating named list vectors from R into rpy2 in Python?

浪尽此生 提交于 2019-12-22 05:44:05
问题 What is the equivalent of the following R code in Rpy2 in python? Var1 = c("navy", "darkgreen") names(Var1) = c("Class1", "Class2") ann_colors = list(Var1 = Var1) It's not clear what ann_colors is. When evaluated in R it gives: > ann_colors $Var1 Class1 Class2 "navy" "darkgreen" Is it an robject.ListVector ? I tried: robjects.ListVector({"Class1": "navy", "Class2": "green"}) but it's not quite it because I'm not sure how to tell the ListVector object that the name of this object is Var1 , i.e

How to preserve Labels when SPSS file (.sav) imported into pandas via rpy?

时光毁灭记忆、已成空白 提交于 2019-12-22 04:33:29
问题 I'm looking to work on a SPSS files (.sav) using pandas . In the absence of the SPSS program, here's what a typical file looks like when converted to .csv: On investigation into what the first two rows signify (I don't know SPSS), it seems that the first row contains the Label s, while the second row contains the VarName s. When I bring the file into pandas thus: import pandas.rpy.common as com def savtocsv(filename): w = com.robj.r('foreign::read.spss("%s", to.data.frame=TRUE)' % filename) w

Installing the R interpeter and R as a shared library uder the same tree

。_饼干妹妹 提交于 2019-12-22 04:18:06
问题 I am a bit confused about how to install R (via compilation) as a shared library. The instructions here (Rpy2) say that I should do the following: # <go to the R source directory> make distclean ./configure --enable-R-shlib make make install but the first make ( make distclean ) would remove any previous installation of R under the same directory tree (e.g. the contents of the bin folder). What if I want to use the same installation for the R interpreter and the shared libraries? For example,

Installing rpy2 without admin privileges

一个人想着一个人 提交于 2019-12-21 17:26:13
问题 I am having trouble installing the Python package rpy2. I have already compiled R as a shared library, but I do not have admin priviledges so I am trying to install rpy2 with: pip install -user rpy2 However, I am getting the following error: ./rpy/rinterface/_rinterface.c:86:31: fatal error: readline/readline.h: No such file or directory compilation terminated. error: command 'gcc' failed with exit status 1 I have downloaded readline to: /some/path/readline-6.2/ where I can see readline.h (I

Rpy2 not finding package

别等时光非礼了梦想. 提交于 2019-12-21 04:14:13
问题 I'm using Rpy2 on windows 7 64 and having trouble loading a package: in R: using(mi) in python: from rpy2.robjects.packages import importr mi=importr('mi') --------------------------------------------------------------------------- RRuntimeError Traceback (most recent call last) <ipython-input-30-2d393a6df544> in <module>() ----> 1 mi=importr('mi') C:\Anaconda\lib\site-packages\rpy2\robjects\packages.pyc in importr(name, lib_loc, robject_translations, signature_translation, suppress_messages,

Python rpy2 and matplotlib conflict when using multiprocessing

谁说胖子不能爱 提交于 2019-12-21 03:53:13
问题 I am trying to calculate and generate plots using multiprocessing. On Linux the code below runs correctly, however on the Mac (ML) it doesn't, giving the error below: import multiprocessing import matplotlib.pyplot as plt import numpy as np import rpy2.robjects as robjects def main(): pool = multiprocessing.Pool() num_figs = 2 # generate some random numbers input = zip(np.random.randint(10,1000,num_figs), range(num_figs)) pool.map(plot, input) def plot(args): num, i = args fig = plt.figure()

rpy2 import is not working

无人久伴 提交于 2019-12-20 20:30:12
问题 I get an error when I try to import rpy2. Here is the code and error. >>> import pandas.rpy.common Traceback (most recent call last): File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\IPython\core\interactiveshell.py", line 2828, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-148-c258a0f70d44>", line 1, in <module> import pandas.rpy.common File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\pandas\rpy\common.py",