Hello Laurent,

I'm sorry about that.

I used to do like this:

import rpy
start = rpy.r.list(...)
lower = rpy.r.list(...)
upper = rpy.r.list(...)
control = rpy.r.nls_control(maxiter=100,tol = 1e-05,minFactor=1./4096)
data = rpy.r.data_frame(x=x, x2=x2,y=y)             # x,x2 and y are numpy.array
rpy.set_default_mode(rpy.NO_CONVERSION)
model = rpy.r.nls(formula, data = data, start = start, lower=lower,
upper=upper, control=control, algorithm="port",trace=True)
rpy.set_default_mode(rpy.BASIC_CONVERSION)
coef=rpy.r.coef(model)


Now I'm trying

import rpy2.robjects as robjects
start = robjects.r.list(...)
lower = robjects.r.list(...)
upper = robjects.r.list(...)
control = ?!?!?!
...
model = robjects.r.nls(formula, data = data ...)

But I don't know how to define the nls.control !

Thanks!


On Fri, Nov 13, 2009 at 3:45 AM, Laurent Gautier <lgaut...@gmail.com> wrote:
> Guilherme Castelao wrote:
>>
>> Hello all,
>>
>> I'm moving to rpy2 but I still didn't get the new syntax. I have two
>> simple questions:
>>
>>
>> - I can create the nls with no trouble as below, but I can't figure
>> out how to create the nls.control with rpy2?
>>
>>
>> model=robjects.r.nls(formula,data=dataf,start=start,control=control,trace=True)
>>
>
> It hard to tell without knowing how you created the objects used in the
> function call.
>
>>
>> - How would be a more elegant way to create a data frame then
>>
>>
>> d={"x":robjects.FloatVector([4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14]),"y":robjects.FloatVector([4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69])}
>> dataf = robjects.r['data.frame'](**d)
>>
>
> That way of creating a data.frame is correct, although not the only way.
>
> # with rpy2-2.1.x-dev
>
> import rpy2.robjects as robjects
>
> dataf = robjects.DataFrame(d)
>
>
> If having to know the type of the R vectors to create is seen as inelegant,
> on can put rpy_classic to use:
>
> import rpy2.rpy_classic as rpy
>
> d={"x":rpy.seq2veq([4.17,5.58,5.18,6.11,4.50,4.61,5.17]),
>   "y":rpy.seq2veq([4.81,4.17,4.41,3.59,5.87,3.83,6.03])}
>
>
> I have to remind myself to write more about creating data.frames in the
> documentation.
>
> L.
>
>
>> Thanks!
>>
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day trial. Simplify your report design, integration and deployment - and
>> focus on what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> rpy-list mailing list
>> rpy-list@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rpy-list
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to