0

I have a dataset and I am able to get summary stats for it using stargazer easily and visually it comes out nice.

Now I want to compare summary stats for different subsets, such as gender for example, but I want the table to visually show the summary stats for all groups (ALL, MALE, FEMALE) side-by-side.

Can this be done easily?

# Summary Stats for Entire Sample (2016)
sumstat1 <- stargazer(subset(cps_data, YEAR == 2016),
          type = 'text',
          summary.stat = c('n','mean','sd'),
          title = 'Summary Stats of Bay Area and Adjacent Counties in 2016')

# Summary Stats for Commuters (2016)
sumstat2 <- stargazer(subset(cps_data, YEAR == 2016 & Commuter == 1),
          type = 'text',
          summary.stat = c('n','mean','sd'),
          title = 'Summary Stats of Commuters in Bay Area and Adjacent Counties in 2016')

# Summary Stats for Noncommuters (2016)
sumstat3 <- stargazer(subset(cps_data, YEAR == 2016 & Commuter == 0),
          type = 'text',
          summary.stat = c('n','mean','sd'),
          title = 'Summary Stats of Noncommuters in Bay Area and Adjacent Counties in 2016')

stargazer(sumstat1,sumstat2,sumstat3,
          type = "text")

The last line of code doesn't really work the same as when I input linear models.

  • Could you provide a code with an example of what you are trying to achieve? That would be useful to provide a solution. – Emmanuel Hamel Apr 09 '23 at 23:41
  • Sorry I'm not sure how to provide a replicable dataset but this is what I have. I updated my post. – Ricardo Gomez Apr 10 '23 at 01:36
  • You may want to read our [tutorial](https://stackoverflow.com/a/5963610/6574038) and update your question accordingly. Cheers! – jay.sf Apr 10 '23 at 07:42

0 Answers0