paljenczy
paljenczy

Reputation: 4899

One single output file for many regressions

Is there a way to write text output from stargazer to one single file from several regressions? As far as I see, I can specify the out= parameter at each single regression but how to tell stargazer to use one single text file?

Upvotes: 2

Views: 1233

Answers (1)

Spacedman
Spacedman

Reputation: 94202

If you grab the output from stargazer you can do what you like with it:

for(m in models){
  s = capture.output(stargazer(m))
  cat(paste(s,"\n"),file="foo",append=TRUE)
  cat("and another one....\n",file="foo",append=TRUE)
}

Maddeningly, stargazer prints the table even when you do out="/dev/null", otherwise you could do this without lots of output with:

for(m in models){
  s = stargazer(m)
  cat(paste(s,"\n"),file="foo",append=TRUE)
  cat("and another one....\n",file="foo",append=TRUE)
}

because stargazer returns the string it just printed (and optionally output to the file too).

Upvotes: 4

Related Questions