考虑以下 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")
导出的电子表格看起来像
标题“传输”不跨越两个子组。标题右侧至少没有边框,但如果我想将标题居中,最好让它跨越两个子组。
有没有办法expss
做到这一点?