[英]Prevent column name wrap in shiny DataTable
我有一個閃亮的DataTable(包“DT”),它有很長的列名(+空格),我希望在沒有包裝名稱的情況下進行渲染 - 即包含2-3行的colnames。 我啟用了水平滾動來嘗試促進這個:
renderDataTable(dataframe_with_long_colnames, ..., options = list(scrollX = TRUE))
但默認情況下,空格會折疊為新行。
我想這回答了我的問題: https : //www.datatables.net/forums/discussion/8923/how-do-you-stop-the-header-from-wrapping-into-multiple-rows但我不確定如何將其轉換為R函數。
此外,此處列出了所有DataTable選項: https : //www.datatables.net/reference/option/
提前致謝。
在ui.R中,在呈現表格的行之前添加以下行:
tags$head(tags$style("#table1 {white-space: nowrap; }")),
替換table1
與xxxxx
從你的輸出語句server.R
文件
output$`xxxxx`<-renderDataTable(.....
你可以簡單地使用nowrap
類:
library(DT)
dat <- data.frame(
"This is a looooooooooooooooonnnnnnnnnnnnggggggg column name" = c(1,2),
"This is also a looooooooooooooooooonnnnnnnnnnnggggggg column name" = c(3,4),
check.names = FALSE
)
datatable(dat, class = "display nowrap")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.