r - 在输出中保持 DT 表的行高相同
问题描述
我想为 DT 表输出设置行常量或固定的高度。对于下表,您可以看到行高的差异。
所以这种情况是当字符数量增加时,例如在这种情况下,在第一个列中的第二行,那么所有行的高度都应该调整为相同。
df <- data.frame(`quote` = c("the trader belongs to","trader have long ralationship withthe same market with my opinion on thaw its implemented mmnnhhh sdfghj fghj kjhgf tyui cvbnm",
"types of trads happens everytime when market slow","trades have leverage with",
"market is continious with the same platform trades"),
`share`= c(43,65,92,23,73),
`times` = c(86,98,55,12,08),
`parts`=c(4,7,4,8,3))
df<-datatable(df,
options = list(columnDefs =
list(list(className = 'dt-center',
targets = "_all"))),rownames = FALSE)
df
就像在 flextable 中一样,我可以执行以下操作,但要为 DT 表寻找固定解决方案或任何功能。
(ncols %in% c(4,5)) {
fl<-width(flxtable, width = d*0.3, j = 1)
fl<-width(flxtable, width = (d*0.7)/(ncols-1), j = 2:ncols)
d is left and right margin of docs template
解决方案
我过去在这方面取得了成功:
DT::datatable(df) %>%
DT::formatStyle(names(df),lineHeight='80%')
感谢帮助我的帖子,但是我现在找不到它了。
推荐阅读
- javascript - 如何使这个句子拆分器 regex safari 兼容?
- javascript - InvalidStateError:无法在“范围”上执行“surroundContents”:范围已部分选择非文本节点
- ruby-on-rails - 如何为 Rails 中的嵌套资源编写此条件语句?
- angular - 在使用 Karma/Jasmine 的 Angular 测试中解决“在 afterAll 中抛出一个错误,不可迭代”
- php - 如何使 Html 下拉列表选择的值打印为 CSV?
- laravel - Laravel:array_push 在 collection->each() 迭代器中不起作用
- asp.net-core - 映射布尔时“可为空的对象必须有一个值”?布尔?
- amazon-web-services - AWS RDS - 备份失败时的事件通知
- postgresql - AWS DMS 任务在 CDC 模式下一段时间后失败
- c# - 如果在提交时抛出异常,C# TransactionScope 会回滚吗?