3

Consider the following MWE:

library(expss)
library(openxlsx)
data(mtcars)
mtcars = apply_labels(mtcars,
                      mpg = "Miles/(US) gallon",
                      cyl = "Number of cylinders",
                      disp = "Displacement (cu.in.)",
                      hp = "Gross horsepower",
                      drat = "Rear axle ratio",
                      wt = "Weight (1000 lbs)",
                      qsec = "1/4 mile time",
                      vs = "Engine",
                      vs = c("V-engine" = 0,
                             "Straight engine" = 1),
                      am = "Transmission",
                      am = c("Automatic" = 0,
                             "Manual"=1),
                      gear = "Number of forward gears",
                      carb = "Number of carburetors"
) 

tbl1 <- mtcars %>% 
  calc_cro_cases(cell_vars = list(hp),
                 col_vars  = list(total(), am))

# save as spreadsheet
wb <- createWorkbook()
sh <- addWorksheet(wb, "Table 1")
xl_write(wb = wb, sheet =  sh, obj = tbl1)
saveWorkbook(wb, "table2.xlsx")

The exported spreadsheet looks like

enter image description here

The title "Transmission" does not span over both subgroups. There is at least no border to the right of the title but if I want to center the header, it would be nice to make it span over both subgroups.

Is there a way in expss to make that happen?

Martin Schmelzer
  • 23,283
  • 6
  • 73
  • 98

0 Answers0