star_panel: To get a panel of stargazer output

View source: R/star_panel.R

star_panelR Documentation

To get a panel of stargazer output

Description

Currently only the same lhs variables and the same summary statistics across all panels are allowed

Usage

star_panel(
  ...,
  starlist = NULL,
  panel.names,
  reg = TRUE,
  same.lhs.vars = TRUE,
  same.summary.stats = TRUE,
  panel.label.fontface = "plain"
)

Arguments

...

stargazer output

starlist

a list of stargazer output

panel.names

the names for the panels in the same order as the stargazer output

reg

(logical) set to TRUE if the panels are regression output; defualt is TRUE

same.lhs.vars

(logical) set to TRUE if all panels have the same left-hand-side variables. Currently, only TRUE is supported

same.summary.stats

(logical) set to TRUE if all panels have the same summary stats. Default is TRUE. If set to FALSE, different panels can have different summary stats. same.summary.stats = FALSE is only supported for regression and so reg must be set to TRUE

panel.label.fontface

The fontface for the panel labels. Options are "plain", "italic", "bold", "bold.italic". Default is "plain".

Value

the updated stargazer output

Examples

## -- Regressoin example -- ##
library(stargazer)
data(mtcars)
##First set up models without weight
mod.mtcars.1 <- lm(mpg ~ hp, mtcars)
mod.mtcars.2 <- lm(mpg ~ hp + cyl, mtcars)
star.out.1 <- stargazer(mod.mtcars.1, mod.mtcars.2, keep.stat = "n")
##Second set of models with weight as a regressor
mod.mtcars.3 <- lm(mpg ~ hp + wt, mtcars)
mod.mtcars.4 <- lm(mpg ~ hp + cyl + wt, mtcars)
star.out.2 <- stargazer(mod.mtcars.3, mod.mtcars.4, keep.stat = c("n", "rsq"))

##stargazer panel -- same summary statistics across panels.
star.panel.out <- star_panel(star.out.1, star.out.2,
                             panel.names = c("Without Weight", "With Weight")
                            )
print(star.panel.out)
##write to a tex file and compile to check output
## Not run: 
tex_write(star.panel.out, file = "my_tex_file.tex", headers = TRUE)

## End(Not run)

##stargazer panel -- different summary statistics across panels.
star.panel.out2 <- star_panel(star.out.1, star.out.2,
                              same.summary.stats = FALSE,
                              panel.names = c("Without Weight", "With Weight")
                             )
print(star.panel.out2)
##write to a tex file and compile to check output
## Not run: 
tex_write(star.panel.out2, file = "my_tex_file2.tex", headers = TRUE)

## End(Not run)

ChandlerLutz/starpolishr documentation built on April 16, 2023, 8:55 a.m.