我有下面的shiny
应用程序,当用户开始在搜索textInput()
中键入一个词时。然后用户按下搜索, Dataframe 将根据此搜索进行子集化。然后我希望在单击Reset
actionButton()
后重新设置表。
## app.R ##
library(shiny)
library(shinydashboard)
library(DT)
col1<-c("sd fgg","df dfg","fgh gdfg")
col2<-c("sd fgg","df dgfg","fgh gdfg")
col3<-c("sd fggg","dfg dfgg","fgghol gdfg")
df<-data.frame(col1,col2,col3)
ui <- dashboardPage(
dashboardHeader(title = "Dataset Inventory"),
dashboardSidebar(
textInput("tt","search",""),
actionButton("ser","Search"),
actionButton("res","Reset")
),
dashboardBody(
dataTableOutput("table")
)
)
server <- function(input, output) {
output$table<-renderDataTable({
input$res
datatable(
d_new <- df[apply(df, 1, function(x) any(grepl(isolate(input$tt), x))), ]
)
})
}
shinyApp(ui, server)
1条答案
按热度按时间a7qyws3x1#
我们可以使用
observeEvent