Guest User

Untitled

a guest
Jan 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. library(shiny)
  2. library(dplyr)
  3. library(DT)
  4.  
  5. mtbetter<-mtcars%>%
  6. mutate(Car_number = c(1:32),
  7. Good_car = F)
  8.  
  9.  
  10. ui <- fluidPage(
  11. textInput(inputId = "text", label = "Filter Car Number"),
  12. actionButton("action", "Go!"),
  13. dataTableOutput(outputId = "table"),
  14. dataTableOutput(outputId = "table2")
  15. )
  16.  
  17. server = function(input, output, session){
  18. mtfinal = reactiveVal(mtbetter)
  19.  
  20. output$table<-renderDataTable({
  21. mtfinal()
  22. })
  23. observeEvent(input$action, {mtfinal()%>%
  24. mutate(Good_car = replace(Good_car, Car_number == input$text, T))})
  25.  
  26. output$table2<-renderDataTable({
  27.  
  28. mtbetter2<-mtbetter%>%
  29. mutate(Good_car = replace(Good_car, Car_number == input$text, T))
  30.  
  31. mtbetter2
  32.  
  33. })
  34.  
  35. }
  36.  
  37. shinyApp(ui, server)
Add Comment
Please, Sign In to add comment