Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7712461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:38:15+00:00 2026-06-01T01:38:15+00:00

I am trying to run a simple linear regression (using rpy2 from Python) and

  • 0

I am trying to run a simple linear regression (using rpy2 from Python) and encountered a strangely worded error when running the script below:

from numpy import array, rec
from numpy.random import normal as nprandom
from rpy2.robjects import numpy2ri, r

foo = array(range(10))
bar = foo + nprandom(0,1,10)

d = rec.fromarrays([foo, bar], names=('foo','bar'))
fit = r.lm('bar ~ foo', data=d)
print fit.rx2('coefficients')

here is the console output:

>>> from numpy import array, rec
>>> from numpy.random import normal as nprandom
>>> from rpy2.robjects import numpy2ri, r
>>> 
>>> foo = array(range(10))
>>> bar = foo + nprandom(0,1,10)
>>> 
>>> d = rec.fromarrays([foo, bar], names=('foo','bar'))
>>> fit = r.lm('bar ~ foo', data=d)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/rpy2/robjects/functions.py", line 82, in __call__
    return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/rpy2/robjects/functions.py", line 33, in __call__
    new_kwargs[k] = conversion.py2ri(v)
  File "/usr/local/lib/python2.6/dist-packages/rpy2/robjects/__init__.py", line 134, in default_py2ri
    raise(ValueError("Nothing can be done for the type %s at the moment." %(type(o))))
ValueError: Nothing can be done for the type <class 'numpy.core.records.recarray'> at the moment.
>>> print fit.rx2('coefficients')

I am running Python 2.6.5 and have numpy version 1.6.1

Does any one know what is causing this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:38:16+00:00Added an answer on June 1, 2026 at 1:38 am

    You need to add:

    rpy2.robjects.activate()
    

    after importing numpy2ri. This SO post references the rpy2 documentation:

    That import alone is sufficient to switch an automatic conversion of
    numpy objects into rpy2 objects.

    Why make this an optional import, while it could have been included in
    the function py2ri() (as done in the original patch submitted for that
    function) ?

    Although both are valid and reasonable options, the design decision
    was taken in order to decouple rpy2 from numpy the most, and do not
    assume that having numpy installed automatically meant that a
    programmer wanted to use it.

    Hope this solves your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Python 2.6 and am trying to run a simple random number
I am trying to run a simple multiple processes application in Python. The main
I'm trying to run a simple query with $this->db in Kohana, but am running
Trying to run a simple svn list svn+ssh://... from within jenkins on os X,
I am trying to run this simple SELECT query using PDO::MySQL, but it does
I am trying to run simple perl dbi example script to connect to mysql
I'm trying to run a simple getJSON to a PHP file using: $.getJSON(loadThumbs.php, {
I am trying to run a simple cgi script after configuring my server. My
When trying to run a simple animation example code in python, I am getting
I am trying to run a simple program using a spring configuration file. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.