Skip to content

Calling/Running python module in R #9

Open

Description

@V69dxz

I installed rPython on my Windows 10 computer. The library seems to work fine. Thanks! As I am new to Python I could use some help running a python module in R. I tried various search strings on Google, but I could not find the answer. Hopefully, you could help me.

The problem is as follows. I installed the kpss module by jejansse. In python, the stem function works well, called by [kpss.stem(t) for t in "Alle eendjes zwemmen in het water".split()]).

Next, I managed to install rPython and loaded the required module using the function python.load("C:/Python27/Lib/kpss.py") . However, I do not know how to call the kpss.stem function. I played around with the assign and call functions, but these functions do not seem to work.

Your help is very much appreciated.

Activity

  1. changed the title [-]Use python module[/-] [+]Calling/Running python module in R[/+] on Jul 6, 2016
  2. V69dxz commented on Jul 7, 2016

    @V69dxz
    Author

    Reading the rPython documentations carefully and with some trail and error, I found the solution myself.

    In R:

    python.exec( "import kpss" )
    t<-c("eendjes")
    python.call( "kpss.stem", t)
    [1] "eend"
    

    What does not work yet is the "for loop", When a string consisting of several words is used, the for loop is ignored and only the last word is stemmed.

    Best,
    Peter

  3. andrejastojic commented on Mar 8, 2018

    @andrejastojic

    python.exec('import pandas as pd')
    python.exec('print(pd.version)')

    results nothing. I use rPython_0.0-6 RJSONIO_1.3-0 and Python 3.6.4.

    Your help is very much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions