Use lapply for multiple regression with formula changing, not the dataset

前端 未结 4 1213
别那么骄傲
别那么骄傲 2020-12-18 09:35

I have seen an example of list apply (lapply) that works nicely to take a list of data objects, and return a list of regression output, which we can pass to Stargazer for n

4条回答
  •  臣服心动
    2020-12-18 09:49

    This should work:

    fit <- lapply(myvars, function(dvar) lm(eval(paste0(dvar,' ~ wt')), data = Boston))
    

提交回复
热议问题