有人能解释一下DT::dataTableProxy是如何工作的吗?
我一直在努力掌握如何使DT::dataTableProxy在我的应用程序中工作,但我无法通过返回所选列的操作 下面的示例中,我尝试修改代码以打印描述性统计数据(使用有人能解释一下DT::dataTableProxy是如何工作的吗?,r,shiny,dt,R,Shiny,Dt,我一直在努力掌握如何使DT::dataTableProxy在我的应用程序中工作,但我无法通过返回所选列的操作 下面的示例中,我尝试修改代码以打印描述性统计数据(使用pastecs)。但唯一呈现的是选定的文本列 #modified UI, adding another verbatimTextOutput ui = ... verbatimTextOutput('foo2') server = ... output$foo2= renderPrint({ x<-input
pastecs
)。但唯一呈现的是选定的文本列
#modified UI, adding another verbatimTextOutput
ui =
...
verbatimTextOutput('foo2')
server =
...
output$foo2= renderPrint({
x<-input$foo_columns_selected
stat.desc(x)
})
结果:
以下答案对非常有帮助:&
require(DT)
library(dplyr)
library(tibble)
ui<-
fluidPage(
selectInput('obj','Choose Name:', choices = c('',my.data$Name), selectize = TRUE),
dateRangeInput('daterange',"Date range:",
start= min(my.data$Date),
end = max(my.data$Date)),
mainPanel(
dataTableOutput('filteredTable'),
dataTableOutput('filteredTable2'),
tableOutput('table')
)
)
server<-function(input,output, session){
filteredTable_data <- reactive({
my.data %>% rownames_to_column() %>% ##dplyr's awkward way to preserve rownames
filter(., Name == input$obj) %>%
filter(., between(Date ,input$daterange[1], input$daterange[2])) %>%
column_to_rownames()
})
##explicit assignment to output ID
DT::dataTableOutput("filteredTable")
output$filteredTable <- DT::renderDataTable({
datatable(
filteredTable_data(),
selection = list(mode = "multiple"),
caption = "Filtered Table (based on cyl)"
)
})
filteredTable_selected <- reactive({
ids <- input$filteredTable_rows_all
filteredTable_data()[sort(ids),] ##sort index to ensure orig df sorting
})
##anonymous
output$filteredTable2<-DT::renderDataTable({
x<-filteredTable_selected() %>% select(starts_with("Value"))
x<-as.data.frame(stat.desc(x))
datatable(
x)
})
}
shinyApp(ui, server)