[R] Using 'sapply' and 'by' in one function

Gabor Grothendieck ggrothendieck at gmail.com
Sun Feb 10 16:15:42 CET 2008


On Feb 10, 2008 10:12 AM, hadley wickham <h.wickham at gmail.com> wrote:
> On Feb 10, 2008 8:25 AM, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> > Actually thinking about this, not only do you not need sapply but you
> > don't even need by:
> >
> > new2 <- transform(new, sex = factor(sex))
> > coef(lm(as.matrix(new2[1:2]) ~ sex/Pred - 1, new2))
>
> Although that's a very slightly different model, as it assumes that
> both sexes have the same error variance.
>

But the output are the coefficients and they are identical.



More information about the R-help mailing list