Questions tagged [rpy2]

RPy is a very simple, yet robust, Python interface to the R Programming Language. It can manage all kinds of R objects and can execute arbitrary R functions (including the graphic functions). All errors from the R language are converted to Python exceptions. Any module installed for the R system can be used from within Python

RPy is a very simple, yet robust, Python interface to the R Programming Language. It can manage all kinds of R objects and can execute arbitrary R functions (including the graphic functions). All errors from the R language are converted to Python exceptions. Any module installed for the R system can be used from within Python.

rpy2 is a redesign and rewrite of rpy. It is providing a low-level interface to R, a proposed high-level interface, including wrappers to graphical libraries, as well as R-like structures and functions.

https://rpy2.bitbucket.io

1203 questions
4
votes
1 answer

How to install rpy2 via conda using default R installation

I use the Anaconda Python distribution on Ubuntu linux and would like to use R magics in IPython notebooks. Is there a way to install rpy2 with the conda distribution and use my current default R installation at /usr/bin/R? My goal is to keep the…
wdnsd
  • 223
  • 3
  • 11
4
votes
1 answer

How to convert an R complex matrix into a numpy array using rpy2

it is clear to me how to convert a float / double R-matrix into a numpy array, but I get an error if the matrix is complex. Example: import numpy as np import rpy2.robjects as robjects import…
Mannaggia
  • 4,559
  • 12
  • 34
  • 47
4
votes
1 answer

"Error while parsing the string" when using RPy2 and dplyr

I'm using R to do some data manipulation. This is a part of a larger project that is mostly in Python, so I'm not using R directly but RPy2 instead. Things work fine until I get to the dplyr part. This works: from rpy2.robjects import r Rcode =…
Parzival
  • 2,004
  • 4
  • 33
  • 47
4
votes
2 answers

Rpy2 Cannot Find R.dll

I am on Windows 7 64bit with Python 2.7.9, have installed R-3.2.0 (also previously tried R-2.12.2 and R-3.1.3 but got the same result), added C:\Program Files\R\R-3.2.0\bin\i386 to the system path, added R_HOME as a system variable with value…
Matt Majic
  • 381
  • 9
  • 18
4
votes
1 answer

rpy2 : Korean characters are not working on rpy2

python code: import rpy2.robjects as robjects rCommand='''gender <- c("남자", "남자", "남자", "여자", "여자", "여자", "여자", "여자") age <- c(23, 25, 27, 29, 31, 33, 35, 37) outdf <- data.frame(gender,…
Bruce Jung
  • 361
  • 1
  • 4
  • 13
4
votes
2 answers

Get field values from rpy2 Random Forest object

I'm trying to run the R Random Forest implementation using Python. I'm using the rpy2 module to get this done easily. Here is a simple example with random generated data: import numpy as np from rpy2.robjects.numpy2ri import numpy2ri from…
Titus Pullo
  • 3,751
  • 15
  • 45
  • 65
4
votes
1 answer

ipython notebook R cell magic as a python function

I have some %rmagic that takes in a dataframe and plots it. I can't do this with the current ggplot implementation in python. So I was wondering if I could use a function to pass the dataframe to a cell that contains R code and possibly return it.…
jwillis0720
  • 4,329
  • 8
  • 41
  • 74
4
votes
2 answers

Can't convert R date ordinal to Python accurately

Following on from the question here: I'm trying to create the series by hand here using Rpy2 import rpy2.robjects as ro from rpy2.robjects.packages import importr import pandas.rpy.common as com pa = importr("pa") ro.r("data(jan)") jan =…
Tahnoon Pasha
  • 5,848
  • 14
  • 49
  • 75
4
votes
1 answer

rpy2 installation error on Windows 8 (Anaconda)

I have the latest Anaconda Python distribution installed on Windows 8 and I am attempting to install the rpy2 package. I initially ran into several issues that I was able to circumvent but I'm now stuck on one particular error that I'm pasting…
Everaldo Aguiar
  • 4,016
  • 7
  • 26
  • 31
4
votes
2 answers

Migrating a logistic regression from R to rpy2

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…
4
votes
2 answers

Rpy2 import external R file

I have a R script in a .R file that I would like to execute. How can I load it? I'd like to source("/path/to/file.R") within the python code, but with this name!
user1595929
  • 1,284
  • 3
  • 13
  • 23
4
votes
0 answers

RPY2 RuntimeError: "No environment variable R_HOME could be found, calling the command 'R RHOME' does not return anything..."

I am running Python 2.7 on Windows 7. First, I installed R and RTools, and changed the following environment variables: RHOME: C:\Program Files\R\R-2.15.2 R_HOME: C:\Program Files\R\R-2.15.2 R_USER: C:\Users\username\Documents And appended the…
Parseltongue
  • 11,157
  • 30
  • 95
  • 160
4
votes
0 answers

Getting data from python to R: rpy2 import pandas.rpy.common error

I am learning python and am just getting into pandas. I am already familiar with R. I would like to be able to create a data frame in python and then somehow get it into R. Could I do this somehow by writing the file to a CSV and then opening it…
bill999
  • 2,147
  • 8
  • 51
  • 103
4
votes
5 answers

rpy2 not working after upgrading R to 3.0.1

I have had a python script that uses rpy2 internally. This script was working until very recently. However, it stopped working now. I got an error that I had not seen previously. I can reproduce the error with the following lines of code: $…
Sam
  • 7,922
  • 16
  • 47
  • 62
4
votes
1 answer

equivalent of "$" in rpy2?

Simple question that I can't seem to find the answer to. How would I get an attribute of an R object in rpy2? For example, what's the equivalent of the R code: m$eval in rpy2?
Doug
  • 387
  • 1
  • 2
  • 15