使用 pander 在 LaTeX 渲染中不分组的行
Rows not grouping in LaTeX rendering with pander
当我将以下 table 呈现为 HTML 时,我得到了预期的行分组:
library(expss)
library(dplyr)
library(pander)
library(knitr)
test_data =
data.table(
division = c(rep("A",5),rep("B",5)),
group = rep(c(rep("alpha",2),rep("beta",3)),2),
subgroup = c("red","orange","yellow","green","blue",
"indigo","violet","black","white","brown"),
ins = rnorm(10),
outs = runif(10),
overs = seq(1,100,10)
)
test_data = apply_labels(test_data,
division = "Department",
group = "Center",
subgroup = "Team",
ins = "In-flow",
outs = "Out-flow",
overs = "Throughput")
test_table =
test_data %>%
tab_cells(ins,
outs,
overs) %>%
tab_cols(division %nest% group %nest% subgroup) %>%
tab_stat_fun(identity) %>%
tab_pivot() %>%
drop_rc() %>%
tab_transpose()
test_table
但是,当我将其呈现为 PDF 时,行分组失败,取而代之的是长串的竖线分隔字符。
pander(test_table)
我认为这更像是 LaTeX 而不是 R 问题,但我不确定它是否不在 pander
的中间。考虑到“上层人士”的偏好,我更愿意将其输出为 PDF。
expss 的默认输出不支持pdf/latex。但是有一个很好的软件包 huxtable
可以与 pdf 一起使用:
所以你需要使用 as_huxtable
:
library(huxtable)
as_huxtable(test_table)
当我将以下 table 呈现为 HTML 时,我得到了预期的行分组:
library(expss)
library(dplyr)
library(pander)
library(knitr)
test_data =
data.table(
division = c(rep("A",5),rep("B",5)),
group = rep(c(rep("alpha",2),rep("beta",3)),2),
subgroup = c("red","orange","yellow","green","blue",
"indigo","violet","black","white","brown"),
ins = rnorm(10),
outs = runif(10),
overs = seq(1,100,10)
)
test_data = apply_labels(test_data,
division = "Department",
group = "Center",
subgroup = "Team",
ins = "In-flow",
outs = "Out-flow",
overs = "Throughput")
test_table =
test_data %>%
tab_cells(ins,
outs,
overs) %>%
tab_cols(division %nest% group %nest% subgroup) %>%
tab_stat_fun(identity) %>%
tab_pivot() %>%
drop_rc() %>%
tab_transpose()
test_table
但是,当我将其呈现为 PDF 时,行分组失败,取而代之的是长串的竖线分隔字符。
pander(test_table)
我认为这更像是 LaTeX 而不是 R 问题,但我不确定它是否不在 pander
的中间。考虑到“上层人士”的偏好,我更愿意将其输出为 PDF。
expss 的默认输出不支持pdf/latex。但是有一个很好的软件包 huxtable
可以与 pdf 一起使用:
所以你需要使用 as_huxtable
:
library(huxtable)
as_huxtable(test_table)