我在rmarkdown/html文档中创建了一个表,其中的列是由针织参数动态选择的。
---
output: html_document
---
```{r echo=FALSE}图书馆(针织品)
头<- c("Col1“、"Col2”、"Col3“、"Col4”、"Col6") #实际上来自于针织参数
testdata <- data.frame(Col1 = c("text“、”超长文本“、"texttext") ),
Col2 = c("looooooooooooooooooooooooooooooooooooooooooong long long long long long text", "textxyz", "abc"), Col3 = 1:3, Col4 = c("2018-11-01", "2018-11-02", "2018-11-03"), Col5 = c(100000, 200000, 300000), Col6 = c(123, 456, 789))testdata <- testdata,colname(Testdata) %in%头
kable(测试数据)
如果我编织它,Col4中的日期将被包装。如何避免只对列Col4进行文本包装,而不更改列名和表的总宽度?
Col4 Col4
------ ------
2018 2018-11-01
-11-01 ===> 2018-11-02
2018 2018-11-03
-11-02
2018
-11-03发布于 2018-11-26 11:05:30
你可以用kableExtra::column_spec
library(kableExtra)
kable(testdata) %>% column_spec(column = 4, width = "100px")https://stackoverflow.com/questions/53477421
复制相似问题