在 R shiny 中使用 DT::renderDataTable 时如何抑制行名称?
How do I suppress row names when using DT::renderDataTable in R shiny?
根据第 2.3 节中的解释 here,我可以通过设置 rownames = FALSE
删除数据表的行名
在 R shiny 中使用 DT::renderDataTable
时如何抑制行名称?以下内容不起作用,因为如果您查看 dataTables options reference 则没有行名选项
output$subsettingTable <- DT::renderDataTable(
subsetTable(), filter = 'top', server = FALSE,
options = list(pageLength = 5, autoWidth = TRUE, rownames= FALSE
))
我的问题与 here 相似。 renderTable
的答案,我已经尝试使那里的答案与 DT::renderDataTable
一起工作,但成功率为零。
请仔细阅读函数的帮助页面,了解哪个参数属于哪个函数。在你的例子中, rownames
参数属于 datatable()
函数,但你实际上将它放在 options
参数中,这肯定是错误的。 DT::renderDataTable()
接受数据对象或 table 小部件作为其第一个参数(同样,请阅读其帮助页面),因此以下任一表达式都应该有效:
DT::renderDataTable(datatable(
subsetTable(), filter = 'top', server = FALSE,
options = list(pageLength = 5, autoWidth = TRUE),
rownames= FALSE
))
DT::renderDataTable(
subsetTable(), filter = 'top', server = FALSE,
options = list(pageLength = 5, autoWidth = TRUE),
rownames= FALSE
)
在后一种情况下,根据帮助页面的 ...
参数的文档,rownames = FALSE
在内部传递给 datatable()
。
根据第 2.3 节中的解释 here,我可以通过设置 rownames = FALSE
在 R shiny 中使用 DT::renderDataTable
时如何抑制行名称?以下内容不起作用,因为如果您查看 dataTables options reference 则没有行名选项
output$subsettingTable <- DT::renderDataTable(
subsetTable(), filter = 'top', server = FALSE,
options = list(pageLength = 5, autoWidth = TRUE, rownames= FALSE
))
我的问题与 here 相似。 renderTable
的答案,我已经尝试使那里的答案与 DT::renderDataTable
一起工作,但成功率为零。
请仔细阅读函数的帮助页面,了解哪个参数属于哪个函数。在你的例子中, rownames
参数属于 datatable()
函数,但你实际上将它放在 options
参数中,这肯定是错误的。 DT::renderDataTable()
接受数据对象或 table 小部件作为其第一个参数(同样,请阅读其帮助页面),因此以下任一表达式都应该有效:
DT::renderDataTable(datatable(
subsetTable(), filter = 'top', server = FALSE,
options = list(pageLength = 5, autoWidth = TRUE),
rownames= FALSE
))
DT::renderDataTable(
subsetTable(), filter = 'top', server = FALSE,
options = list(pageLength = 5, autoWidth = TRUE),
rownames= FALSE
)
在后一种情况下,根据帮助页面的 ...
参数的文档,rownames = FALSE
在内部传递给 datatable()
。