How to call ltm function using rpy package in python

M

Mohit Khanna

I am trying the following code--

from rpy import *
r.library("ltm")

dat= #some data frame or matrix
r.ltm(r('dat~z1'))

error coming is---
RPy_RException: Error in eval(expr, envir, enclos) : object 'dat' not found

Please tell me the right way to call ltm function using rpy library
 
P

Piet van Oostrum

Mohit Khanna said:
I am trying the following code--

from rpy import *
r.library("ltm")

dat= #some data frame or matrix
r.ltm(r('dat~z1'))

error coming is---
RPy_RException: Error in eval(expr, envir, enclos) : object 'dat' not found

Please tell me the right way to call ltm function using rpy library

Your problem is that the 'dat' object is in the Python world but not in
the R world. However, the expression r('dat~z1') is looking for a 'dat'
object in the R world. So you must copy the Python object to the R
world.

I don't know if this will work in rpy, but it does work in rpy2. Rpy2
has much better possibilities than rpy. But just try it:

r['=']('dat', dat)
r.ltm(r('dat~z1'))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top