Hi,
I am new to shiny and I am stuck with a problem. I want the user to enter a binary matrix through checkboxes - but I don't get the changes through, i.e. whatever I click in the checkboxes, there is no change in the output.
Here is my code so far:
library(shiny)
library(markdown)
library(relations)
prbm <- matrix (c(TRUE,FALSE,FALSE,TRUE), 2, 2)
# Define UI ----
ui <- navbarPage("",
tabPanel("Your Turn",
fluidRow(column(5, "Enter your Relation!")),
fluidRow(column(1,
checkboxInput("pr1", "(1, 1)", prbm[1,1]),
checkboxInput("pr2", "(1, 2)", prbm[1,2])),
column(1,
checkboxInput("pr3", "(2, 1)", prbm[2,1]),
checkboxInput("pr4", "(2, 2)", prbm[2,2])),
column(10, plotOutput("PRplot"), textOutput("value"))
)
)
)
# Define server logic ----
server <- function(input, output) {
reactive(prbm[2,2] <- input$pr4)
reactive(prbm[2,1] <- input$pr3)
reactive(prbm[1,2] <- input$pr2)
reactive(prbm[1,1] <- input$pr1)
output$PRplot <- renderPlot({plot(relation(incidence=prbm))})
output$value <- renderText(as.character(matrix(1*prbm,2,2)))
}
# Run the app ----
shinyApp(ui = ui, server = server)
Any help is highly appreciated!