Kable Extra和Rmardown的美学
我正在以r为样式的以下代码以样式的表格,
library(kableExtra)
library(knitr)
item<-c("question1.NATURALES" , "question2.NATURALES" , "question3.NATURALES" , "question4.NATURALES",
"question5.NATURALES" , "question6.NATURALES" , "question7.NATURALES" , "question8.NATURALES" ,
"question9.NATURALES" ,"question10.NATURALES")
key<-c("C", "A", "A", "C", "B", "D", "B", "A", "D", "C" )
A<-c(0 ,3 ,0, 1, 0, 0 ,0 ,0, 2 ,0)
B<-c(0, 0, 1 ,0, 3, 0, 3, 1, 0, 1 )
fa<-data.frame("item"=item,"key"=key, "A"=A,"B"=B)
fa %>%
kbl(escape = FALSE,booktabs = TRUE,longtable=TRUE) %>%
kable_styling(fixed_thead = T,repeat_header_text = "continuaci\\'on",
repeat_header_continued="contin\\'ua en la siguiente p\\'agina") %>%
kable_paper(c("striped","condensed","scale_down","repeat_header"),
full_width = FALSE)
tmp<- data.frame(t(
data.frame(t(select(fa, -item, -key))) %>%
mutate_all(function(i) cell_spec(i, color = ifelse(i == max(i), "green", "red")))
), row.names = NULL)
cbind(fa[1],fa[ 2], tmp) %>%
kbl(escape = FALSE,booktabs = TRUE,longtable=TRUE) %>%
kable_styling(fixed_thead = T,repeat_header_text = "continuaci\\'on",
repeat_header_continued="contin\\'ua en la siguiente p\\'agina") %>%
kable_paper(c("striped","condensed","scale_down","repeat_header"),
full_width = FALSE)
但是当打印pdf时,结果如下
它不会显示样式化或显示页面的单词更改,但如果我在控制台我得到以下
我想知道发生了什么,因为在PDF中,它以不太美学的方式向我展示了我。
当然,如果您还有其他建议,这是欢迎的。
I am reproducing the following code in R to style my table
library(kableExtra)
library(knitr)
item<-c("question1.NATURALES" , "question2.NATURALES" , "question3.NATURALES" , "question4.NATURALES",
"question5.NATURALES" , "question6.NATURALES" , "question7.NATURALES" , "question8.NATURALES" ,
"question9.NATURALES" ,"question10.NATURALES")
key<-c("C", "A", "A", "C", "B", "D", "B", "A", "D", "C" )
A<-c(0 ,3 ,0, 1, 0, 0 ,0 ,0, 2 ,0)
B<-c(0, 0, 1 ,0, 3, 0, 3, 1, 0, 1 )
fa<-data.frame("item"=item,"key"=key, "A"=A,"B"=B)
fa %>%
kbl(escape = FALSE,booktabs = TRUE,longtable=TRUE) %>%
kable_styling(fixed_thead = T,repeat_header_text = "continuaci\\'on",
repeat_header_continued="contin\\'ua en la siguiente p\\'agina") %>%
kable_paper(c("striped","condensed","scale_down","repeat_header"),
full_width = FALSE)
tmp<- data.frame(t(
data.frame(t(select(fa, -item, -key))) %>%
mutate_all(function(i) cell_spec(i, color = ifelse(i == max(i), "green", "red")))
), row.names = NULL)
cbind(fa[1],fa[ 2], tmp) %>%
kbl(escape = FALSE,booktabs = TRUE,longtable=TRUE) %>%
kable_styling(fixed_thead = T,repeat_header_text = "continuaci\\'on",
repeat_header_continued="contin\\'ua en la siguiente p\\'agina") %>%
kable_paper(c("striped","condensed","scale_down","repeat_header"),
full_width = FALSE)
But when printing the pdf the result is as follows
It doesn't show stylized or show the words of the page change but if I run it in the console I get the following
I would like to know what is happening because in the pdf it shows me in a less aesthetic way.
Of course, if you have any other advice, it's welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尝试使用rmarkDown打印您的桌子。我发现我们可以通过使用
latex_options =“条纹”
在kable_styling()
函数中获得PDF中的条纹样式。该代码在PDF中的以下两个表中产生:
I tried to print your table using Rmarkdown. I found that we can get the striped style in PDF by using
latex_options = "striped"
inkable_styling()
function.The code results in the following two tables in PDF: