How can I name stargazer in the model list?

I just ran a series of models with a nice and flexible way to split data code. I had a good list of formulas and models in the configuration section, in which I lapply to get a list of model objects. Now I want to display them in stargazer , but it does not accept the list object. How can I do this without entering each item in the list?

Playable example:

 require(stargazer) l <- list() l$lm1 <- lm(rating ~ complaints + privileges + learning + raises + critical, data=attitude) l$lm2 <- lm(rating ~ complaints + privileges + learning, data=attitude) ## create an indicator dependent variable, and run a probit model attitude$high.rating <- (attitude$rating > 70) l$prbt <- glm(high.rating ~ learning + critical + advance, data=attitude, family = binomial(link = "probit")) stargazer( l[[1]], l[[2]], l[[3]], title="Results", align=TRUE, type="text") 
+7
r stargazer
source share
2 answers

Please make sure you are using an updated version of the package. Starting with version 4.5.3 (available on CRAN from November 2013), stargazer was able to accept object lists exactly as you expected:

stargazer(l, title="Results", align=TRUE, type="text")

+5
source share

Use do.call :

 do.call( stargazer, l ) 

However, this eliminates passing 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 need to add named arguments to the list:

 l$type <- "text" l$align <- TRUE l$title <- "Results" do.call( stargazer, l ) 

Another way to do this is to curry using the stargazer function:

 require(functional) sgCurried <- Curry( stargazer, type="text" ) # all arguments to stargazer go in here do.call( sgCurried, l ) 
+4
source share

All Articles