Update docs regarding automatic numpy to rpy2 conversion

Issue #273 resolved
Antony Lee
created an issue

I feel that the docs regarding automatic numpy to rpy2 conversion are a bit unclear. It starts by saying that one should use

from rpy2.robjects.numpy2ri import numpy2ri
ro.conversion.py2ri = numpy2ri

but then adds that conversion only gets turned on after calling numpy2ri.activate (and this is emphasized in the red box).

If my understanding is correct, the assignment ro.conversion.py2ri = numpy2ri is in fact not necessary, and will actually only allow automatic converting of numpy arrays while making rpy2 unable to pass other objects to R; the correct approach is just to call numpy2ri.activate without the assignment.

Comments (2)

  1. Laurent Gautier

    Thanks. This seems to be an old statement no longer valid with recent releases.

    The only steps needed are:

    from rpy2.robjects import numpy2ri
    numpy2ri.activate()
    

    Would you be able to make a pull request ?

  2. Log in to comment