【发布时间】:2015-09-27 21:43:16
【问题描述】:
亲爱的 Shiny 和 DT 大师们! 我正在尝试在我闪亮的应用程序中使用自然排序插件,但它似乎不起作用。我认为它与以前版本的 Shiny 或/和之前的 DT 包一起使用。有谁能够帮我?请参阅下面的示例(我正在尝试对最后一列进行排序):
服务器.R
library(shiny)
require(DT)
shinyServer(function(input, output) {
output$example <- DT::renderDataTable({
table = cbind(LETTERS[1:5],matrix(1:20,nrow=5),c(1,2,3,10,"a"))
table = rbind(c("filtered",round(rnorm(5),3)),table)
DT::datatable(table,
rownames = FALSE,
extensions = list(FixedColumns = list(leftColumns = 1)),
options = list(
columnDefs = list(list(type = "natural", targets = "_all"))))
})
})
ui.R
library(shiny)
require(DT)
shinyUI(
fluidPage(
tags$head(
tags$script(src = "http://cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js", type = "text/javascript"),
tags$script(src = "http://cdn.datatables.net/plug-ins/1.10.7/sorting/natural.js", type = "text/javascript")
),
DT::dataTableOutput('example')
)
)
【问题讨论】:
-
看起来您的初始表加载不正确。
-
抱歉,输入错误,但思路还是一样...
-
对所有列进行排序对我来说非常有效。是否出现任何错误或警告?
标签: r datatables shiny dt