X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 18 Feb 2016 04:53 AM by  anon
Help the error of calling rpy2
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
18 Feb 2016 04:53 AM
    Hi, guys: According to the "Calling the R Statistical Package from IDL via Python", rpy2 with Anaconda2 successfully installed on my windows 64bit system. I can get the graphics windows with the following commands: IDL> !null = Python.run("from rpy2.robjects.packages import importr") % Loaded DLM: PYTHON27. % Program caused arithmetic error: Floating underflow % Program caused arithmetic error: Floating illegal operand IDL> !null = Python.run("import rpy2.robjects.numpy2ri") IDL> !null = Python.run("rpy2.robjects.numpy2ri.activate()") IDL> importr = Python.importr IDL> graphics = importr('graphics') IDL> !null = graphics.plot(findgen(10), main="Eigen values") But when I write those command into a procedure, like: PRO test_rpy2 !null = Python.run("from rpy2.robjects.packages import importr") !null = Python.run("import rpy2.robjects.numpy2ri") !null = Python.run("rpy2.robjects.numpy2ri.activate()") importr = Python.importr graphics = importr('graphics') !null = graphics.plot(findgen(10), main="Eigen values") END "test_rpy2" stopped at "graphics = importr('graphics')" and the error was given: % Compiled module: TEST_RPY2. % Python: Unable to index object of type: "function" So why? thanks! Dave

    Zachary Norman



    Basic Member


    Posts:173
    Basic Member


    --
    18 Feb 2016 04:06 PM
    Hi Dave, Try adding the compile_opt statement to your procedure which would look like this: PRO test_rpy2 compile_opt idl2 !null = Python.run("from rpy2.robjects.packages import importr") !null = Python.run("import rpy2.robjects.numpy2ri") !null = Python.run("rpy2.robjects.numpy2ri.activate()") importr = Python.importr graphics = importr('graphics') !null = graphics.plot(findgen(10), main="Eigen values") END -Zach (Harris)

    Deleted User



    New Member


    Posts:
    New Member


    --
    18 Feb 2016 05:38 PM
    Very thanks, Zach. It works!
    You are not authorized to post a reply.