Chris,

Giving an example that works (or does not work, actually) straight out
of a copy/paste
is making it easier for anyone willing to help.

I had a quick try at getting one, but cannot run the example in the
documentation
for the function 'plsr'.

import rpy
rpy.r.library('pls')
rpy.r.data('yarn')
rpy.set_default_mode(rpy.NO_CONVERSION)

#--- this one is working
fit = rpy.r('plsr(density ~ NIR, 6, data = yarn, validation = "CV")')

#--- this one is not working
yarn = rpy.r.get('yarn')
yarn_pls = rpy.r.plsr('density ~ NIR', 6, data = yarn, validation = "CV")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
rpy.RPy_RException: Error in formula[[2]] : subscript out of bounds

A closer look at the code in 'plsr' reveals the combo match.call() and
eval(cl, parent.frame())
that is likely causing trouble.
plsr <-
function (..., method = pls.options()$plsralg)
{
    cl <- match.call()
    cl$method <- match.arg(method, c("kernelpls", "widekernelpls",
        "simpls", "oscorespls", "model.frame"))
    cl[[1]] <- as.name("mvr")
    res <- eval(cl, parent.frame())
    res$call <- match.call()
    res
}


#... can you continue with the exact code leading to the problem ?


Thanks,


L.





2008/6/13 Chris Arthur <[EMAIL PROTECTED]>:
> My message seemed to get a bit lost in that discussion so just to bring
> it back ...
>
> Changing that to mod instead of r(mod) results in
>
> predicted=r.predict(*r(mod)*, type='response', ncomp = 10, newdata = accFAS )
>
>
> gives the following error
>
> Traceback (most recent call last):
>  File "C:\Documents and Settings\Administrator\Desktop\pls\pls.py", line
> 40, in <module>
>   predicted=r.predict(mod, type='response', ncomp = 10, newdata = accFAS )
> RPy_RException: Error in eval(predvars, data, env) :
>  numeric 'envir' arg not of length one
>
> which is why I had thought it was r(mod) originally; or is this error
> telling me something else is wrong?
>
> What does  "numeric 'envir' arg not of length one" refer to anyway?
>
> Chris
>
> Chris Arthur wrote:
>> Hi Gregory,
>>
>> Changing that to mod instead of r(mod) results in the following error
>>
>> Traceback (most recent call last):
>>   File "C:\Documents and Settings\Administrator\Desktop\pls\pls.py",
>> line 40, in <module>
>>     predicted=r.predict(mod, type='response', ncomp = 10, newdata = accFAS )
>> RPy_RException: Error in eval(predvars, data, env) :
>>   numeric 'envir' arg not of length one
>>
>> which is why I had thought it was r(mod) originally; or is this error
>> telling me something else is wrong?
>>
>> Chris
>>
>> Gregory Warnes wrote:
>>
>>>
>>> On Jun 10, 2008, at 9:20AM , Chris Arthur wrote:
>>>
>>>
>>>> Thanks Gregory, that "y ~ ." syntax solves my problems. and allows my to
>>>> pull out the PLSR data I wanted, but leads me to my next problem.
>>>>
>>>>
>>> Glad to help.
>>>
>>>
>>>
>>>> I then try to use my model to predict the value of the matrix accFAS
>>>> predicted=r.predict(*r(mod)*, type='response', ncomp = 10, newdata =
>>>> accFAS )
>>>>
>>>>
>>> I think your problem comes from the r(mod).  This form expects a
>>> string to be evaluated in r.  Try this instead"
>>>
>>>
>>>> predicted=r.predict(*mod*, type='response', ncomp = 10, newdata =
>>>> accFAS )
>>>>
>>> -G
>>> ------------------------------------------------------------------------
>>>
>>> -------------------------------------------------------------------------
>>> Check out the new SourceForge.net Marketplace.
>>> It's the best place to buy or sell services for
>>> just about anything Open Source.
>>> http://sourceforge.net/services/buy/index.php
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> rpy-list mailing list
>>> rpy-list@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/rpy-list
>>>
>>>
>>
>>
>> -------------------------------------------------------------------------
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://sourceforge.net/services/buy/index.php
>> _______________________________________________
>> rpy-list mailing list
>> rpy-list@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rpy-list
>>
>>
>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list
>

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to