【发布时间】:2020-08-10 11:02:12
【问题描述】:
我想做一个性别和疾病之间的列联表。当我将 R.markdown 用于 pdf 时。报告,我使用kableExtra 来自定义表格。当它们不是 data.frame 时,KableExtra 不能很好地制作表格。所以他们用tableby做了丑陋的桌子
有了这个data.frame,我得到了。
library(kableExtra)
library(arsenal)
set.seed(0)
Disease<-sample(c(rep("Name of the first category of the disease",20),
rep("Name of the Second category of the disease",32),
rep("Name of the third category of the disease",48),
rep("The category of those who do not belong to the first three categories",13)))
ID<-c(1:length(Disease))
Gender<-rbinom(length(Disease),1,0.55)
Gender<-factor(Gender,levels = c(0,1),labels = c("F","M"))
data<-data.frame(ID,Gender,Disease)
当我使用 R.markdown (pdf) 运行此分析的结果时,我得到了这种表格
有两个问题,渴了KableExtra::不处理字符&nbsp;&nbsp;&nbsp;
其次,当我将tableby 与kableExtra 一起使用时,我无法自定义列宽,因为我想扩大包含变量名称的列,因为我确实在处理变量值名称很长的数据。但是如果我使用knitr::的kable,则字符&nbsp;&nbsp;&nbsp;被删除,但是表格没有按比例缩小,并且没有显示一部分。我认为knitr 有很多限制。
我该如何处理这个问题?或者是否有另一个函数可以在 R.markdown(pdf 格式)中使用 p.value 制作漂亮的列联表。
【问题讨论】:
-
你有没有找到解决这个问题的方法?
标签: r knitr kable kableextra