[EMAIL PROTECTED] wrote:
> The following code (taken from the pls package manual) works in R...
> 
> <code>
> 
> data(yarn)

> from rpy import *
> r.library("pls")
> 
> yarn=r.data('yarn', package="pls")

> Its probably a newbie error but I'd really appreciate it if someone can
> tell me what it is I'm doing wrong.

  When playing with Rpy, it's alwys a good idea to check every step is 
doing as you expect. If you look at your Python variable 'R' you'll see 
something:

 >>> yarn=r.data('yarn',package='pls')
 >>> yarn
'yarn'

  Hmmm, it's just the string 'yarn'...

  This is because you've misunderstoon what data('yarn') does in R. It 
adds the object 'yarn' to the search path, it doesn't return it.

  If you do:

  r.data('yarn',package='pls')
  yarn = r.yarn

  then your python variable 'yarn' will now have the value of the R 
object 'yarn', so that when you pass the python variable in:

mod = r.pcr(formula, ncomp = 9, data = yarn, validation = "CV")

  it gets the right thing. Possibly. You might bet bit by python-R 
conversion here...

Barry

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to