2008/6/1 <[EMAIL PROTECTED]>:
> Thanks for that Barry thats much clearer now, I had done print yarn, and
> didn't understand why it had returned the string "yarn". Its all clear now
> though.
>
> Making the change you suggest though moves me forward but then throws the
> following error
> "Traceback (most recent call last):
> File "pls.py", line 8, in <module>
> mod = r.pcr(formula, 9, yarn, validation = 'CV')
> rpy.RPy_RException: Error in as.data.frame.default(data, optional = TRUE) :
> cannot coerce class "function" into a data.frame
> "
The error message is looking strange.
> I'm guessing that by passing as yarn i'm mucking it up. But can't see how.
> r.data instead of yarn does the same thing
I suspect a confusion here.
Didn't Barry mentionned
yarn = r.yarn
rather than
yarn = r.data
?
> Chris
>
>> [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
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/rpy-list
>>
>
>
>
> -------------------------------------------------------------------------
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rpy-list
>
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list