I'm actually surprised to find that no one has asked this question. Here it goes.
I have a 3 models, first 2 computed for black people and the last one for whites. I produce a regression output with stargazer and over the first two models I write the column label "Black" using column.labels. I label the remaining column "White". So, 3 models, two with the same column label and the last with another one.
However, I want to also add another column label above the first model specifying "Males"(I also mean above the "Black" label) and add a similar label for the 2 last models specifying "Female".
I can't see a way to add the second columns labels above the Racial category.
library(stargazer)
data <- data.frame(dv1=rnorm(100),dv2=rnorm(100),dv3=rnorm(100),race=sample(c(1,0) ,100, replace = T),
iv=sample(c(1,0),100,replace = T))
m1 <- lm(dv1 ~ + iv, data = data, subset = race == 1)
m2 <- lm(dv2 ~ + sqrt(iv), data = data, subset = race == 0)
m3 <- lm(dv3 ~ + iv, data = data, subset = race == 0)
models <- stargazer(m1,m2,m3, type = "text", column.labels = c("Blacks","Whites"), column.separate = c(2,1),
dep.var.labels.include = FALSE)