[R] lm: eval(parse(text=)) works on one side y/x but not on both?

Matthieu Stigler matthieu.stigler at gmail.com
Mon Nov 30 07:54:58 CET 2009


Yes, was wondering that other code line did not change so much :-)

Thanks a lot!

2009/11/30 Gabor Grothendieck <ggrothendieck at gmail.com>:
>
>
> On Sun, Nov 29, 2009 at 9:16 AM, Gabor Grothendieck
> <ggrothendieck at gmail.com> wrote:
>>
>> By the way, if you really do want to create the formula anyways then:
>>
>>    ix <- 1:2
>>    left <- paste(names(freeny)[ix], collapse = ",")
>>    fo <- as.formula(paste("cbind(", left, ") ~ ."))
>>    lm(fo, freeny)
>>
>> or possibly replace last line with:
>>
>>    eval(substitute(lm(fo, freeny))
>>
>> which will cause the formula to appear in the lm output.
>
> This last line should have been:
>
> This last line should have been:
>
>  eval(substitute(lm(fo, freeny), list(fo = fo)))
>
>




More information about the R-help mailing list