我正在尝试使用和包DT::datatable
在 Tufte html 文档中包含一个。但是,即使我使用选项设置列的宽度,或者使用或选项设置
输出的宽度,仍然会沿页面、主列和边距列的整个宽度显示!正如您在下图中看到的,它位于直方图下方,但应仅在主列中放置在其旁边。Bookdown
knitr
columnDefs
kintr
fig.fullwidth = FALSE
out.with = '50%'
DT::datatable
DT::datatable
我的问题很简单,你知道如何DT::datatable
只在Tufte html 书籍的主栏中显示 a 吗?您可能会看到产生DT::datatable
非常感谢你的帮助。
{r high-range-cv, echo = FALSE, fig.fullwidth = FALSE}
sketch = htmltools::withTags(table(
class = 'display',
thead(
tr(
th(rowspan = 2, 'Indicator'),
th(colspan = 2, 'Highest Variability'),
th(colspan = 2, 'Lowest Variability')
),
tr(
lapply(rep(c('Country', 'CV'), 2), th),
th("Diff")
)
)
))
diff_ind %>%
select(ind_name, max_cty, max, min_cty, min, diff) %>%
datatable(colnames = c("Indicator", "Country", "Max", "Country", "Min", "Diff"),
container = sketch,
rownames = FALSE,
filter = 'top',
extensions = 'FixedColumns',
options = list(pageLength = 6,
autowidth = TRUE,
columnDefs = list(list(width = '50px', targets = c(2, 4, 5)),
list(width = '100px', targets = c(1, 3)),
list(width = '300px', targets = 0)
),
scrollX = TRUE,
fixedColumns = TRUE)) %>%
formatRound(c("max", "min", "diff") , 2)