使用kableextra vignette,我可以成功地从 如果我编织成pdf,则“通过multi_row单元对行进行分组”部分可产生预期的输出。
library(tidyverse)
library(kableExtra)
collapse_rows_dt <- expand.grid(Country = sprintf('Country with a long name %s', c('A', 'B')),
State = sprintf('State %s', c('a', 'b')),
City = sprintf('City %s', c('1', '2')),
District = sprintf('District %s', c('1', '2'))) %>%
arrange(Country, State, City) %>%
mutate_all(as.character) %>%
mutate(C1 = rnorm(n()), C2 = rnorm(n()))
kable(collapse_rows_dt, "latex", booktabs =T,align ="c",linesep ='') %>%
collapse_rows(1:3,row_group_label_position ='stack')
但是,如果我编织成html(并更改kable调用)。堆叠的第一行不再堆叠。
library(tidyverse)
library(kableExtra)
collapse_rows_dt <- expand.grid(Country = sprintf('Country with a long name %s', c('A', 'B')),
State = sprintf('State %s', c('a', 'b')),
City = sprintf('City %s', c('1', '2')),
District = sprintf('District %s', c('1', '2'))) %>%
arrange(Country, State, City) %>%
mutate_all(as.character) %>%
mutate(C1 = rnorm(n()), C2 = rnorm(n()))
kable(collapse_rows_dt, "html", booktabs =T,align ="c",linesep ='') %>%
collapse_rows(1:3,row_group_label_position ='stack')
同一示例不在小插图的html version中。在寻找解决方案之后,我无法确定html中是否不支持此功能,是否存在错误或是否有解决方法来达到类似的效果。