Ah, you got the famous "object of type closure is not subsettable" error.
We can use some [[
magic to help us here:
cfs <- lapply(lm.test, `[[`, "coefficients")
The double bracket is a function that extracts a variable name - this effectively loops over the following code:
cf_i <- lm.test[[i]][["coefficients"]]
where i
is the number of models in lm.test
EDIT:
More simply,
cfs <- lapply(lm.test, coef)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…