Re: [julia-users] R's update(Update and Re-fit a Model) in Julia?

2016-11-16 Thread Hongwei
Thanks a million, Milan!!!

Hongwei

On Tuesday, November 15, 2016 at 1:32:36 PM UTC-5, Milan Bouchet-Valat 
wrote:
>
> Le lundi 14 novembre 2016 à 14:18 -0800, Hongwei Liu a écrit : 
> > Hi guys, 
> > 
> > I am new to Julia and I have trouble in finding a similar function in 
> > Julia that has the ability of "update" in R. 
> > 
> > For example, set formula = y ~ x1 + x2 
> > 
> > In R, I can use update(formula, D  ~ . ) to change the formula from y 
> > ~ x1 + x2 to D ~ x1 + x2 
> > 
> > In Julia, the formula's type is DataFrames.Formula and I have 
> > searched online and Dataframes document for a long time but still 
> > couldn't find the answer. 
> > 
> > So my question is: 
> > 
> > Is there are such a function in Julia? If not, is there a way to 
> > modify a formula directly? 
> I don't think we provide such a function yet, but you can easily do 
> that manually. 
>
> Use dump() to see what the formula object consists in: 
> julia> dump(y ~ x1 + x2) 
> DataFrames.Formula 
>   lhs: Symbol y 
>   rhs: Expr 
> head: Symbol call 
> args: Array{Any}((3,)) 
>   1: Symbol + 
>   2: Symbol x1 
>   3: Symbol x2 
> typ: Any 
>
> Here, you can just change the rhs (right hand side) argument: 
> julia> f = y ~ x1 + x2 
> Formula: y ~ x1 + x2 
>
> julia> f.lhs = :D 
> :D 
>
> julia> f 
> Formula: D ~ x1 + x2 
>
>
> Regards 
>
> > Thanks a lot!! 
> > 
> > Hongwei 
>


Re: [julia-users] R's update(Update and Re-fit a Model) in Julia?

2016-11-15 Thread Milan Bouchet-Valat
Le lundi 14 novembre 2016 à 14:18 -0800, Hongwei Liu a écrit :
> Hi guys,
> 
> I am new to Julia and I have trouble in finding a similar function in
> Julia that has the ability of "update" in R.
> 
> For example, set formula = y ~ x1 + x2
> 
> In R, I can use update(formula, D  ~ . ) to change the formula from y
> ~ x1 + x2 to D ~ x1 + x2
> 
> In Julia, the formula's type is DataFrames.Formula and I have
> searched online and Dataframes document for a long time but still
> couldn't find the answer.
> 
> So my question is:
> 
> Is there are such a function in Julia? If not, is there a way to
> modify a formula directly?
I don't think we provide such a function yet, but you can easily do
that manually.

Use dump() to see what the formula object consists in:
julia> dump(y ~ x1 + x2)
DataFrames.Formula
  lhs: Symbol y
  rhs: Expr
head: Symbol call
args: Array{Any}((3,))
  1: Symbol +
  2: Symbol x1
  3: Symbol x2
typ: Any

Here, you can just change the rhs (right hand side) argument:
julia> f = y ~ x1 + x2
Formula: y ~ x1 + x2

julia> f.lhs = :D
:D

julia> f
Formula: D ~ x1 + x2


Regards

> Thanks a lot!!
> 
> Hongwei


[julia-users] R's update(Update and Re-fit a Model) in Julia?

2016-11-14 Thread Hongwei Liu
Hi guys,

I am new to Julia and I have trouble in finding a similar function in Julia 
that has the ability of "update" in R.

For example, set formula = y ~ x1 + x2

In R, I can use update(formula, D  ~ . ) to change the formula from y ~ x1 
+ x2 to D ~ x1 + x2

In Julia, the formula's type is DataFrames.Formula and I have searched 
online and Dataframes document for a long time but still couldn't find the 
answer.

So my question is:

Is there are such a function in Julia? If not, is there a way to modify a 
formula directly?

Thanks a lot!!

Hongwei