How do I call stargazer on a list of models?
Use do.call
:
do.call( stargazer, l )
However, this precludes passing in arguments in the usual way:
> do.call( stargazer, l, type="text" )Error in do.call(stargazer, l, type = "text") : unused argument (type = "text")
Therefore, you have to add the named arguments to the list:
l$type <- "text"l$align <- TRUEl$title <- "Results"do.call( stargazer, l )
Another way to do this is to curry the stargazer function:
require(functional)sgCurried <- Curry( stargazer, type="text" ) # all arguments to stargazer go in heredo.call( sgCurried, l )