rpy2

rpy2 error with datetime64[ns] pandas series

≯℡__Kan透↙ 提交于 2021-01-28 18:25:55
问题 How can one pass datetime64[ns] data to R from rpy2? The following simple case: import pandas as pd import rpy2.robjects as robjs from rpy2.robjects import pandas2ri pandas2ri.activate() dti = pd.date_range('2018-01-01', periods=3, freq='H') robjs.r.summary(dti) fails with a ValueError: ValueError: Unknown numpy array type "datetime64[ns]". with rpy2 version 3.3.4 and pandas 1.0.5. 回答1: Instead of passing DatetimeIndex to R as you do: dti = pd.date_range('2018-01-01', periods=3, freq='H')

Unable to install rpy2

妖精的绣舞 提交于 2021-01-28 05:23:16
问题 On mac 10.12.6, pip install rpy2 is giving me "Failed building wheel for rpy2" I tried the this. Any ideas what to look at next? Here is the error log: ---------------------------------------- Failed building wheel for rpy2 Running setup.py clean for rpy2 Failed to build rpy2 Installing collected packages: rpy2 Running setup.py install for rpy2 ... error Complete output from command /Users/me/Applications/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders

R kernel crashes while loading R package using rpy2

一世执手 提交于 2021-01-28 03:45:37
问题 First of all, I’m new to rpy2 / jupyter so please don’t judge me if this isn’t the correct place to ask my question. I am trying to set up an integrated workflow for data analysis using R and Python and I encounter the following error: I am on Ubuntu 19.04. running a conda environment using Jupyter 1.0.0, Python 3.7.4, R 3.5.1, r-irkernel 1.0.2 and rpy2 3.1.0 and I installed the R-package Seurat through R. When I create a Jupyter notebook using the R-kernel, I can load Seurat with library

Travis CI: error when installing rpy2

牧云@^-^@ 提交于 2021-01-27 12:01:00
问题 I am developing a python package that depends on rpy2 . I would like to run test with Travis CI. In .travis.yml I install conda and run tests with green : language: python # Be strict when checking our package warnings_are_errors: true # command to install dependencies install: # http://conda.pydata.org/docs/travis.html - wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh; - bash miniconda.sh -b -p $HOME/miniconda - export PATH="$HOME/miniconda/bin:$PATH

How to pass a list to R in rpy2 and get result back

≡放荡痞女 提交于 2021-01-05 12:27:59
问题 I am trying to use rpy2 for the first time. Let's say I have in python a list l = [1,2,3,4,5,6] I want to do call in R ks.test(l, pexp) How can I do that? My initial try is #!/usr/bin/python import rpy2.robjects as robjects l = [1,2,3,4,5] f = robjects.r(''' f<-function(l){ ks.test(l, pexp) }''') print f(l) This clearly isn't the right way to do it as I get Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic Traceback (most recent call last): File ".

How to pass a list to R in rpy2 and get result back

試著忘記壹切 提交于 2021-01-05 12:27:50
问题 I am trying to use rpy2 for the first time. Let's say I have in python a list l = [1,2,3,4,5,6] I want to do call in R ks.test(l, pexp) How can I do that? My initial try is #!/usr/bin/python import rpy2.robjects as robjects l = [1,2,3,4,5] f = robjects.r(''' f<-function(l){ ks.test(l, pexp) }''') print f(l) This clearly isn't the right way to do it as I get Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic Traceback (most recent call last): File ".

How to pass a list to R in rpy2 and get result back

大兔子大兔子 提交于 2021-01-05 12:22:36
问题 I am trying to use rpy2 for the first time. Let's say I have in python a list l = [1,2,3,4,5,6] I want to do call in R ks.test(l, pexp) How can I do that? My initial try is #!/usr/bin/python import rpy2.robjects as robjects l = [1,2,3,4,5] f = robjects.r(''' f<-function(l){ ks.test(l, pexp) }''') print f(l) This clearly isn't the right way to do it as I get Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic Traceback (most recent call last): File ".

How to pass a list to R in rpy2 and get result back

早过忘川 提交于 2021-01-05 12:21:27
问题 I am trying to use rpy2 for the first time. Let's say I have in python a list l = [1,2,3,4,5,6] I want to do call in R ks.test(l, pexp) How can I do that? My initial try is #!/usr/bin/python import rpy2.robjects as robjects l = [1,2,3,4,5] f = robjects.r(''' f<-function(l){ ks.test(l, pexp) }''') print f(l) This clearly isn't the right way to do it as I get Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic Traceback (most recent call last): File ".

How to execute S4 class method in Python (using rpy2)?

我怕爱的太早我们不能终老 提交于 2020-12-13 11:17:09
问题 I have made the following S4 class in R, its constructor takes a variable called 'A', which is a string. The class has a method called 'test_method', which takes as input a string 'B' and returns whether 'A' equals 'B'. test_class <- setRefClass( "test_class", fields=list(A="character"), methods = list( test_method = function(B) { if (A==B) { return('yes') } else { return('no') } } ) ) Now, I can make an instance of this class and execute 'test_method' on it: object <- test_class(A='hello')