Try this also:

lapply(df[,which(sapply(df, is.factor))], function(reg)lm(df$x~reg))

On 09/10/2007, Jiong Zhang, PhD <jizhang@chori.org> wrote:
>
> Hi All,
>
> I want to run regression (lm) on my dependant variable by gender and race.
> How do I integrate the "by" function in lm?
>
> thanks.
>
> jiong
> The email message (and any attachments) is for the sol...{{dropped:20}}

