R中KableExtra中的列名格式

问题描述 投票:0回答:1

Latex命令没有按照我的意图格式化列名。

library(kableExtra)
kable(test,"latex", col.names = c('Mean','\\textit{N}' ,'Strongly\nDisagree','Disagree','Neither Agree\norDisagree','Agree','Strongly\nAgree'))

我得到的输出是:

https://www.dropbox.com/s/xvl7lfh94bl2274/Kable%20Table.PNG?dl=0

我尝试了乳胶命令和R-markdown命令。

N应该是斜体的,强烈的不同意,不同意或不同意,并且非常同意应该分为两条线。

r textwrapping kableextra italics
1个回答
0
投票
test_data <- data.frame(Mean = runif(5, 3.71, 7.72),
                        N = sample(57:59, 5, replace = TRUE),
                        sd = c(1, rep(0, 4)),
                        d = rep(1, 5),
                        naod = sample(1:4, 5, replace = TRUE),
                        a = sample(5:12, 5, replace = TRUE),
                        sa = sample(37:44, 5, replace = TRUE)

kable(test_data,"latex" ,booktabs=T, align="c",col.names=linebreak(c('Mean','\\textit{N}' ,'Strongly\n Disagree','Disagree','Neither Agree\n or Disagree','Agree','Strongly\n Agree')),row.names = T,escape=F)%>%
  row_spec(0,align = "c")
© www.soinside.com 2019 - 2024. All rights reserved.