为什么我的操作按钮和选择输入不起作用?

问题描述 投票:0回答:1

这是代码

我希望任何人都可以帮助或指导我。

r shiny
1个回答
0
投票

您没有调用 UI 和服务器来了解细节。一探究竟。一般来说,一个中包含的内容需要另一个中包含的内容。

library(shiny)
library(shinythemes)
library(shinydashboard)
library(shinyMatrix)

ui <- fluidPage(
  
  navbarPage(
    title = "DETERMINANTS CALCULATOR",
    theme = shinytheme("sandstone"),
    tabPanel(value = "Home", 
             icon("home"),
             fluidRow(
               column(
                 width=12,
                 height=20,
                 tags$h1("Determinants", 
                         height = 4, 
                         style = "font-weight: bold; text-align; center;"),
                 mainPanel(
                   width = 3,
                   height = 8, 
                   style = "border-style: solid; border-color: black;",
                   br(),
                   selectInput("matrix", 
                               "Choose a matrix dimension:", 
                               c("2", "3"),
                               actionButton("set", 
                                            "Set as Matrix"),
                   ),
                 ),
               ),

               mainPanel(
                 uiOutput("matrixInput"),
                 br(),
                 actionButton("calculate", "Calculate"),
                 tags$h3("Result of the Matrix", 
                         style = "font-weight: bold; text-align;center;"),
                 textOutput("metdetanswer")
               )
             )               
    ),
    tabPanel(value = "About", icon("address-card"),
             sidebarPanel(
               h2("About the App", 
                  style = "font-weight: bold;"),
               p("This web application complies with the final project or learning evidence to CS111, Advance Algebra for the first semester. This application can solve a 2x2 and 3x3 determinant matrix and multiply to row from echelon form to its diagonal element.", 
                 style = "font-weight:bold; text-center;")
             )
    )
  )  
)

# BOANGMOMENTS
server <- function(input, output) {
  valuedet <- eventReactive(input$trigger, {
    matrix(
      nrow = input$matdimension,
      ncol = input$matdimension
    ) # end matrix
  }  # close eventReactive
  ) # end eventReactive
  
  observeEvent(valuedet(), {
    output$matrixInput <- renderUI({
      matrixInput(
        inputId = "matrixdet", 
        label = "Create your own Matrix",
        value = valuedet(), 
        rows = list(names = FALSE), 
        cols = list(names = FALSE)
      ) # end matrixInput
    }) # end renderUI
  }) # end observeEvent
  
  observeEvent(input$calculate, {
    output$matdetanswer <- renderText(
      det(input$matrixdet)
    )
  })
  } # end server

  # Run the application 
  shinyApp(ui = ui, server = server)
© www.soinside.com 2019 - 2024. All rights reserved.