Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to call ltm function using rpy package in python

Reply
Thread Tools

How to call ltm function using rpy package in python

 
 
Mohit Khanna
Guest
Posts: n/a
 
      01-08-2013
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
 
Reply With Quote
 
 
 
 
Piet van Oostrum
Guest
Posts: n/a
 
      01-11-2013
Mohit Khanna <(E-Mail Removed)> writes:

> 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'))
--
Piet van Oostrum <(E-Mail Removed)>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
rpy: parsing arrays from python to R Frank Python 0 03-27-2007 07:50 PM
Why does Rpy/R-plot work under PythonWin, but not under commandline/IDLE? Bo Peng Python 1 01-09-2006 07:05 AM
Rpy: displaying multivariate data with pairs() and coplot() malv Python 0 12-12-2005 09:04 PM
Rpy: displaying multivariate data with pairs() and coplot() malv Python 0 12-12-2005 08:51 PM



Advertisments