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?
Asked
Active
Viewed 1,175 times
2

paljenczy
- 4,779
- 8
- 33
- 46
-
Do you mean something different than passing multiple model objects to be displayed in a single table? – joran May 28 '14 at 16:40
-
Yes, multiple models' tables to be saved to one single text file. Thanks. – paljenczy May 28 '14 at 16:48
-
Well, I'm just trying to clarify, because `stargazer()` will by default accept multiple model objects. There are numerous examples in the docs and the vignette. So I thought maybe you meant something different... – joran May 28 '14 at 16:51
1 Answers
4
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).

Spacedman
- 92,590
- 12
- 140
- 224